Is there an easy way to make gnuplot automatically show y1=0 and y2=0 at the same height in the image while the y1 and y2 axes have different scales?
The only way I am aware is to make sure the proportional distance from zero on the high and low bounds are the same for y1 and y2
For example
set yrange [-1:2]
and set y2range [-10:20]
would work because -1 is to -10 as 2 is to 20.
Here's an example
#!/usr/bin/gnuplot -p
set term wxt #not important
unset key
set autoscale
set xrange [0:1]
set xzeroaxis #shows a dotted line where y=0 for y1.
set yrange[-1:2]
#set y2range[-10:20] #if you set an explicit range, it obviously won't work unless you plan it perfectly (like this)
#set y2range[-10:] #this does the minimum to get the plot in the frame (here -10 is the minimum, but the maximum seems to not really matter
#set y2range[:20]
#set y2range[:] #this is equivalent to just not having a set y2range line.
set xtics 0.2
set ytics 0.3
set y2tics 1
set mxtics 5
set mytics 5
set my2tics 5
set ytics nomirror #makes y1tics only show up on the left
f(x)=1
g(x)=10
plot f(x) axis x1y1 lc rgb 'blue', \
g(x) axis x1y2 lc rgb 'red';
Asked by T. Zack Crawford
(232 rep)
Jun 10, 2019, 08:14 PM
Last activity: Jun 13, 2019, 04:57 PM
Last activity: Jun 13, 2019, 04:57 PM