|||
(1)画竖直的errorbar
例子:
close all;figure;
h=bar(volume_month_mean./1e6); %--volume_month_mean 为12×2的矩阵
set(h,'BarWidth',0.9);
hold on;
set(h(1),'facecolor',[139 35 35]./255) %--设置bar的颜色
set(h(2),'facecolor','k')
ngroups = size(volume_month_mean,1);
nbars = size(volume_month_mean,2);
groupwidth =min(0.8, nbars/(nbars+1.5));
hold on;
for i = 1:nbars %--画errorbar
x = (1:ngroups) - groupwidth/2 + (2*i-1) * groupwidth / (2*nbars);
errorbar(x,volume_month_mean(:,i)/1e6,volume_month_std(:,i)/1e6,'o','color',[.5 .5 .5],'linewidth',2);
end
for n=1:12
if n<=9
time_lab{n,1}=['0' num2str(n)];
else
time_lab{n,1}=num2str(n);
end
end
set(gca,'XTickLabel',time_lab,'fontsize',14,'linewidth',2)
ylim([-0.5 2.5])
xlim([0 13])
set(gca,'ytick',-0.5:0.5:2.5)
(2)画水平errorbar
例子:
close all;figure;
h=bar(volume_mean./1e6); %--volume_mean是4*2的矩阵
set(h,'BarWidth',0.9);
hold on;
set(h(1),'facecolor',[139 35 35]./255)
set(h(2),'facecolor','k')
ngroups = size(volume_mean,1);
nbars = size(volume_mean,2);
groupwidth =min(0.8, nbars/(nbars+1.5));
hold on;
for i = 1:nbars
x = (1:ngroups) - groupwidth/2 + (2*i-1) * groupwidth / (2*nbars);
errorbar(x,volume_mean(:,i)/1e6,volume_std(:,i)/1e6,'o','color',[.5 .5 .5],'linewidth',2);
end
view(-90,90)
set(gca,'xdir','reverse','ydir','reverse','XTickLabel',{'Winter','Spring','Summer','Autumn'},'fontsize',14,'linewidth',2)
ylim([-0.5 2.5])
set(gca,'ytick',-0.5:0.5:2.5)
ye_xylabel(gca,' ','Volume[Sv]')
legend('A','B','location','NorthEast')
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-27 00:40
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社