Grouped bar plot with manually specified colors for each bar in the groups

1 回表示 (過去 30 日間)
Pavlov
Pavlov 2013 年 10 月 30 日
My basic question is this: how can I manually specify the different colors that will be used to color my bars? In this specific instance (code below), I have 4 groups each with 4 bars. Each bar represents the magnitude of responsiveness of a neuron to a particular stimulus. Each of the 4 bars for each group is differently colored according to MATLAB's default settings. However, I would like to specifiy the colors manually in order to make these data consistent with colors I use elsewhere.
I generate the bar plot like so:
figure; h = bar(dFF_ROIs); if units == ['Z-score'] ylabel('{\bf Z-score (mean dF/F)}') end hold on for b = 1:numROI set(gca,'XTick',[1:numROI],'XTickLabel', ROIs2) end xlabel('{\bf ROI analyzed (area, stim location)}') title(['{\bf', mouse, ' ', num2str(unique(Reps)), '-day avg.}']) legend(x_axis_units,'location','Northeast')
There are 4 stimulus types, specified in a cell array called 'x_axis_units' which you can see appears in my legend function at the end. Additionally, I have specific an array of the color I want:
CS_colormat = [0 1 0; 1 0 0; 0 0 1; 0 0 0];
Ideally, I'd like to assign each of these 4 colors to each of the 4 bars in each group (in this case, 4 groups of 4 bars). In other words, the first bar would be green, the second red, the third blue, and the fourth black.
Is there a straightforward way to do this? Unfortunately there doesn't seem to be a simple 'color' input for teh bar function like there is for the plot function.
Thanks!

回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by