MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在左轴上绘制线图,在右轴上绘制条形图 (https://www.labfans.com/bbs/showthread.php?t=22263)

poster 2019-11-29 02:55

在左轴上绘制线图,在右轴上绘制条形图
 
在具有两个y轴的图形中,一个用于线图(左),一个用于条形图(右),我希望该条形图位于折线图下方,以获得更好的可见性,而不是使其升高。

[IMG]https://i.stack.imgur.com/wDdAx.jpg[/IMG]

正如您在这张图片上所看到的(我希望您能看到),条形图显示了降水的演变,而不同的线显示了叶绿素指数的变化,我的问题是条形图覆盖了这些线,我想线要向上。

这是我的脚本:

figure yyaxis right bar (meteo(:,1),meteo(:,14)); ylabel('Precipitation (mm)'); hold on for i=1:6; a = []; b = []; color = ['r' 'm' 'b' 'c' 'g' 'y']; for j=0:6 a(i,j+1)=matrice_5(j*6+i,1);%jour b(i,j+1)=matrice_5(j*6+i,3);%moyenne end hold on yyaxis left plot(a(i,:),b(i,:),color(i),'LineWidth',1.5); end title('Evolution of the mean of the chlorophyll index (HNT) - Charlotte variety'); xlabel('Day (2013)') ylabel('Chlorophyll index (HNT)') axis([735390 735442 32 50]); set(gcf,'Position',[645 206 701 477]); datetick('x','dd mmm','keepticks') h=legend('0','50','100','150','200','250','precipitation','Location','best'); v = get(h,'title'); set(v,'string','Nitrogen rate in kg/ha'); set(h,'Position', [0.1793 0.1494 0.1127 0.2446]); hold on plot([735422 735422],[32 49],'Color',[.3 .3 .3]); hold off 到目前为止,我只得到一半的结果。我想将条形图放在左轴(左y轴)上,并将线图放在右轴上。我想将叶绿素指数保持在左侧。

谢谢您的帮助



[url=https://stackoverflow.com/q/37709988]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 19:40

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.