我有以下代码:
%initialize variables
titles = {'1a', '1b', '2a', '2b', '3a', '3b', '4a', '4b', '5a', '5b', '6a', '6b', '7a', '7b', '8a', '8b', '9a', '9b', '10a', '10b', '11a', '11b', '12a', '12b', '13a', '13b', '14a'};
antibodies = {'Rel-A','p-Rel-A','IkBa','p-IkBa','A20'};
x_axis = {'PBS','GOX','TNF','L','M','H'};
colours = {'r','g','b','m','c'};
Y_axis = 'Fold TNF (OD)';
%plot graphs
h = figure('name','Cytoplasm,Averaged,1h');
for i=1:5,
subplot(5,1,i)
barwitherr(std_error{2}(i,1:6),averaged_data{2}(i,1:6),'BarWidth',0.7) %note that barwitherr is a downloadable function
set(get(gca,'YLabel'), 'String', Y_axis)
set(gca, 'XTick', 1:6, 'XTickLabel', x_axis,'fontsize',18);
title(antibodies(i))
end
h=subplot(5,1,1);
set(h,'ylim',[0,15]);
h=subplot(5,1,3);
set(h,'ylim',[0,4]);
h=subplot(5,1,4);
set(h,'ylim',[0,4]);
h=subplot(5,1,5);
set(h,'ylim',[0,4]);
这很好地生成了我的图形,只是我想要改变各个子图的单个条形图的颜色。也就是说,你将如何更改第一个小块绿色的第一个条形图,而剩下的则保持蓝色?
干杯
发布于 2014-08-15 04:01:32
如果我理解正确,你就使用这一功能。
如果是,那么您可以修改barwitherr.m的代码以更改颜色。
希望能帮上忙。
发布于 2014-08-15 03:50:51
我想解决办法是用
[nelements , centers] = hist(Ydata,XData);
获取感兴趣的数据的bin计数,然后对数据应用一些阈值,以便只有低于阈值的数据是绿色的,其余的数据是蓝色的。
例如:
CentersBelowTreshold = centers(centers < MinCutoffValue);
ElementsBelowTreshold = nelements(centers < MinCutoffValue);
CentersAboveTreshold = centers(centers > MinCutoffValue);
ElementsAboveTreshold = centers(centers > MinCutoffValue;
然后绘制条形图。我想您可以修改barwitherr的源代码,因为它基本上用附加的输入参数绘制条形图。
bar(CentersBelowTreshold,ElementsBelowTreshold,'g')
hold on
bar(CentersAboveTreshold,ElementsAboveTreshold,'b')
hold off.
https://stackoverflow.com/questions/25324531
复制