Plotting two axes in gnuplot

You can have the axes handled automatically without you having to scale them yourself and keep auto-scaling:

set terminal jpeg
set output 'graph.jpg'

set xrange [-10:10]
set ytics 10 nomirror tc lt 1
set ylabel '2*x' tc lt 1
set y2tics 20 nomirror tc lt 2
set y2label '4*x' tc lt 2
plot 2*x linetype 1, 4*x linetype 2 axes x1y2

output of the script

Leave a Comment