curious
curious

Reputation: 105

Plot different set of Y for a single set of X

I have a single set of value for X. Otherwise I have three set of Y values let it be y1,y3,y4. Now, I am unable to plot X versus y1,y3,y4 in the same plot in GNUPLOT. Can anyone help me out to solve this problem?

Upvotes: 0

Views: 1340

Answers (3)

patthoyts
patthoyts

Reputation: 33193

You use the 'axes' option to plot. Here is an example drawing 2 plots using the same X values:

set xrange [-4:4]
plot cos(x) axes x1y1 title "cos" with linespoints lt 1 pt 7 ps 0.0,\
     sin(x) axes x1y2 title "sin" with linespoints lt 2 pt 8 ps 0.0
pause mouse any "Click the mouse or hit any key to terminate"

If you run that with gnuplot it should look like the following image example double plot

Upvotes: 1

Pascail
Pascail

Reputation: 374

If you have your data in a file, assuming data.dat

X1   Y1    Y2    Y3
1    0.1   0.2   0.3
...  ...   ...   ...

you can plot Y1, Y2 and Y3 versus X with

plot 'data.dat' using 1:2, '' u 1:3, '' u 1:4

u being the shortcut for using.

Upvotes: 2

Yehia
Yehia

Reputation: 528

If all y values are of the same units, then one y axis would suffice. If not, you can plot x against up to 2 y-axes (here's how).

Upvotes: 1

Related Questions