how to plot with double y-axis?

1 visualización (últimos 30 días)
Hydro
Hydro el 14 de Oct. de 2017
Editada: Hydro el 14 de Oct. de 2017

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 comentario
Hydro
Hydro el 14 de Oct. de 2017
Editada: Hydro el 14 de Oct. de 2017
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'})

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by