how to plot with double y-axis?

1 次查看(过去 30 天)
Hydro
Hydro 2017-10-14
编辑: Hydro 2017-10-14

Hello, Below is my code for producing double y-axis plot. on the left axis, i have discharge data while on the right axis I have precipitation in reverse direction. i would like to increase the space in between. Also, need to further subdivide the y-axis on both sides as well as labeling both y-axis. any help would be appreciated.

figure()
[AX,H1,H2] =plotyy(x,Mean_Gauge4,x,Mean_prec,'bar','bar');
set(AX(2),'YDir','reverse')
set(H1,'FaceColor','r','barwidth',0.3) 
set(H2,'FaceColor','b','barwidth',0.3)
axis(AX(1), 'tight');
axis(AX(2), 'tight');
alpha(AX(2), .5)
set(gca,'xtick',1:12,'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})
  1 个评论
Hydro
Hydro 2017-10-14
编辑:Hydro 2017-10-14
hello, I figure it out. here is the code in case someone needs it.
figure()
[AX,H1,H2] =plotyy(x,Mean_Gauge4,x,Mean_prec,'bar','bar');
set(AX(2),'YDir','reverse')
set(H1,'FaceColor','r','barwidth',0.3)
set(H2,'FaceColor','b','barwidth',0.3)
axis(AX(1), 'tight');
axis(AX(2), 'tight');
set(AX(2),'YLim',[0 150],'YTick',[0:10:150])
set(AX(1),'YLim',[0 50],'YTick',[0:10:50])
box(AX(1),'off'
alpha(AX(2), .5)
set(gca,'xtick',1:12,'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by