EDIT: Gnuplot does now in fact now support a for loop, you can read about it here
As I understand gnuplot doesn't have a for loop, although you can generate one of sorts as follows:
Make a file "loop.gp" containing
const = const + 1
#... some gnuplot commands ...
if(const<100) reread
then in a gnuplot terminal, or script write,
const = 3; load "loop.gp";
This will give you a simple loop.
(this example is taken from the misc. section of http://t16web.lanl.gov/Kawano/gnuplot/index-e.html)
For your particular answer you might try adding arrows rather than paremetric lines,
eg.
set arrow from const,1 to const,4 nohead
will do much the same thing.
In this case you loop.gp could be
const = const + repititionperiod
#... some gnuplot commands ...
set arrow from const,1 to const,4 nohead
if(const<calculatedupperlimit) reread
and you would run you loop with
const = 1; repititionperiod=2;calculatedupperlimit = 10; load "loop.gp"; replot;
The replot plots the arrows.
If you "just" want the lines and nothing else - then you will need to feed a graph to actually plot (a set of arrows doesn't count). The example you gave could then be used to plot the first vertical line.
hope this helps.
Tom
The "-" is used to specify that the data follows the plot command. So if you use it, you'll need to do something like:
echo "set datafile separator \",\"; plot '-' using 1:2 with lines, '' using 1:3 with lines;" | cat - datafile.dat | gnuplot -p
(Quoting above probably needs to be escaped).
What're you looking for is this:
plot '< cat -'
Now, you can do:
cat test | sed ... | gnuplot -p "plot '< cat -' using ..."
Note that you might need to feed in the input data via stdin multiple times if you're using options with plot, like so:
cat testfile testfile | gnuplot -p "plot '< cat -' using 1, '' using 2"
In the above case, testfile must end with a line that has the sole character 'e' in it.
Manual reference
Best Answer
If you are on a Unix system (i.e. not Windows) you can use
'<cat'
instead of'-'
to read from stdin:Then you can do
cat data.txt | gnuplot script.gp
. However, in the specific case you mention in your question, with the plot in the for loop, you read the input three times. So sending the data through stdin is not appropriate, since the data will be gone after the first time it is read.