Multiple Y-axes are important when comparing data ranges that are relatively large. A Twinx function is provided in Meteoinfolab to generate a new Axes based on the existing coordinate system (Axes), which causes the existing Axes not to draw the right y-axis, and the newly generated Axes draws only the right y-axis. The YAxis function can set the y-axis of a axes, the first parameter is a axes object, you can set the y-axis color and offset (shift), and the 3rd y-axis must be offset to avoid the gland for graphs over 2 y-axes.
Double y-Axis diagram:
Multiple y-axis graphs:
Script Program:
Ax1 =axes () yaxis (ax1, Color='b') T= Arange (0.01, 10.0, 0.01) S1=exp (t) plot (T, S1,'B -', linewidth=2) Xlabel ('Time (s)') Ylabel ('Exp', color='b') Ax2=Twinx (AX1) yaxis (ax2, Color='R') S2= Sin (2*pi*t) plot (T, S2,'R.') Ylabel ('Sin', color='R') Show ()
AX1 = Axes (position=[0.113,0.15,0.7,0.8]) YAxis (ax1, Color='b') line1= Plot ([0, 1, 2], [0, 1, 2],'B -', label="Density") Xlabel ('Distance') Ylabel ('Density', color='b') title ('mutiple Y Axis Sample') Ax2=Twinx (AX1) yaxis (ax2, Color='R') Line2= Plot ([0, 1, 2], [0, 3, 2],'R', label="Temperature") Ylabel ('Temperature', color='R') Ax3=Twinx (AX1) YAxis (AX3, Shift=60, color='g') Line3= Plot ([0, 1, 2], [50, 30, 15],'g', label="Velocity") Ylabel ('Velocity', color='g') Lines=[Line1, Line2, Line3]legend (lines) show ()
Meteoinfolab Script Example: Multi-y-axis diagram