Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plotting multiple data lines based no data from stdin

424 views
Skip to first unread message

rolf_...@hotmail.com

unread,
Nov 8, 2007, 8:53:21 AM11/8/07
to
Hi,

I have data like the following:

2006-06-02 245760 10240
2006-07-14 1167360 20480
2006-08-29 2375680 24576
2006-10-17 2375680 8192
2006-11-02 2375680 8192
2006-11-07 2375680 2300928
2006-11-27 2375680 1785856
2007-01-12 2375680 729088

and I want to get a graph with 2 lines (one for each y-column):

|
|-._ _.---
| '--------'
|-._
| '--------._.---
|
+---------------------

I know that "using" helps me in this scenario.
And it works if the data comes from a file:

plot "file.dat" using 1:2 with lines \
"" using 1:3 with lines

But I am processing this from within a perl script and have the data
in some memory structure so I would rather use stdin for the data,
instead of writing to a file and making gnuplot read this file.

plot "-" using 1:2 with lines \
"" using 1:3 with lines
... <perl feeds the datalines to stdin> ...
e

gives a "no data point found in specified file" error.
The same if I repeat the hyphen.

plot "-" using 1:2 with lines \
"-" using 1:3 with lines

A simple one graph per stdin data approach works:

plot "-" using 1:2 with lines
... < data from stdin > ...
e

(so I guess the syntax that I use is correct ...)

I know that gnuplot starts a new graph line if the data
is separated into blocks by an empty line. But that doesn't
really help me, because then both lines would have the the
same style/color and title.

Temporary files is really something that I would like to avoid.
The keyword is CGI, and using a pipe and stdin would get
me around file locking.

Thanks in advance for any ideas.

Rolf.

Hans-Bernhard Bröker

unread,
Nov 8, 2007, 6:19:19 PM11/8/07
to
rolf_...@hotmail.com wrote:
> plot "-" using 1:2 with lines \
> "" using 1:3 with lines
> ... <perl feeds the datalines to stdin> ...
> e

You should read "help datafile special-filenames" again. It even
contains an example doing exactly what you're trying to.

rolf_...@hotmail.com

unread,
Nov 9, 2007, 7:40:32 AM11/9/07
to
On Nov 9, 12:19 am, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:

>
> You should read "help datafile special-filenames" again. It even
> contains an example doing exactly what you're trying to.

Thanks for pointing me out to the right topic in documentation.

If the datalines are repeated and also the final e indicator, plotting
the two lines works from stdin.

plot "-" using 1:2 with lines \

"-" using 1:3 with lines


... <perl feeds the datalines to stdin> ...
e

... < feed the same data again for the 2.line >
e

That's the way how it goes with manuals: If you know where it is
you find it. After going through all the options and descriptions
with "plot" I gave up and decided to consult the Usenet.

Thanks again, Rolf.

0 new messages