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