I want to have a single .plt file storing both data and gnuplot commands. My data looks like
# x1 y1 x2 y2
1 2 3 4
5 6 7 8
and corresponds to two plots: (x1,y1) and (x2,y2).
I know I can use "-"
like:
plot "-" using 1:2
# x1 y1 x2 y2
1 2 3 4
5 6 7 8
e
But that would generate only one plot, i.e., (x1,y1). I'm trying to do something like
plot "-" using 1:2, "-" using 3:4
# x1 y1 x2 y2
1 2 3 4
5 6 7 8
e
but obviously that doesn't work since gnuplot expects a new set of data from the standard input for the second "-"
.
Notes:
reread
but that requires two files. I really want only one file.You can't do this without modifying something about the way you input the data. When feeding gnuplot data via standard input, it expects multiple data sets to be delimited with two blank lines between them, or to be interleaved on successive lines. The options are:
Feed the two data sets into different plot commands altogether.
Change the file format so that data sets have blank lines between them, then reference them all with index.
Change the file format so that alternating lines represent different data sets, then reference them all with every.
Put the data into one file, the plotting script into another, and then reference the data file more than once with different using clauses each time.
There's an intro to the every and index commands starting at How do I plot several data sets in a single file? Those are the only facilities built into gnuplot for this sort of thing, and neither does exactly what you were asking about. it's good you've already modified the data formatting, because this wasn't ever going to work as you'd originally hoped.
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