Is it possible to pass to plot data in a string?
I mean do something like this:
plot "09-13-2010,2263.80 09-14-2010,2500" using 1:2 with lines
Is it possible to pass to plot data in a string?
I mean do something like this:
plot "09-13-2010,2263.80 09-14-2010,2500" using 1:2 with lines
Quoting from the documentation:
either a
<function>
or the name of a data file enclosed in quotes
So, no.
It is possible to do something like:
set xdata time
set timefmt "%m-%d-%y"
plot "< echo '09-13-2010,2263.80 09-14-2010,2500' | tr ' ' '\n' | tr ',' ' '" using 1:2 with lines
Where the <
character indicates to Gnuplot that we want our input from the output of a command. Gnuplot separates records with a newline. Groups of records are separated by a blank record. Within a record, the default column separator is a space. In the above example tr
is used to split your data into lines, and the rewrite the lines into records.
Another way to plot your data from a string is to use the "-" input specifier, and then load the data in from the command line. A program could easily emit the following:
set xdata time
set timefmt "%m-%d-%y"
plot '-' using 1:2 with lines
09-13-2010 2263.80
09-14-2010 2500
e
Your best bet is to use an input file like:
09-13-2010 2263.80
09-14-2010 2500
Assuming the input file is named mydata.txt
, you can then plot it with the commands:
set xdata time
set timefmt "%m-%d-%y"
plot 'mydata.txt' using 1:2 with lines
All the examples above give you something like:
If you want to plot two data series using dates and the `-' input you could do the following:
set xdata time
set timefmt "%m-%d-%y"
plot '-' using 1:2 title "Series 1" with lines,'-' using 1:2 title "Series 2" with lines
09-13-2010 2263.80
09-14-2010 2500
e
09-13-2010 2500
09-14-2010 2263.80
e
The previous example gives: