I have multiple datasets I want to plot in a single figure:
plot "data1a.txt", "data1b.txt", "data1c.txt", "data2.txt"
I want to have two y-axes with different ranges.
yrange=[0:10]
y2range=[-10:10]
This is easily done on gnuplot if you only have two datasets. The first dataset uses yrange
(with it's axis on the left hand side), and the second dataset uses y2range
(with the axis on the right hand side).
Now here's the question. I want to plot datasets data1a.txt
, data1b.txt
and data1c.txt
using yrange
, and data2.txt
using y2range
. How do I do this on a single figure with two y-axes?
As documented here:
plot {<ranges>}
{<function> | {"<datafile>" {datafile-modifiers}}}
{axes <axes>} {<title-spec>} {with <style>}
{, {definitions,} <function> ...}
you can see that the axes
are used in the plot command. After setting the ranges of your y-axes with
set yrange [y1min:y1max]
set y2range [y2min:y2max]
you can specify which axis you want to use in your plot with
plot "data.txt" axes x1y1
if you want to plot it against the first y-axis or
plot "data.txt" axes x1y2
if you want to plot it against the second y-axis.
Also see this example of how to use multiple axis in gnuplot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With