Reputation: 1197
I am getting data from a script stuff.pl
and want to plot dynamically into one graph. So I am going to use a loop in Gnuplot (v4.6 patchlevel 3) which leads me to following problem:
Using the file TEST.gp
:
xCol=2; yCol=3
set term x11 1
plot '< stuff.pl' u xCol:yCol
xCol=4; yCol=5
set term x11 1
set autoscale y
replot '< stuff.pl' u xCol:yCol
pause 1
and run it via gnuplot TEST.gp
my graph isn't scaled proper. The plot is just showing the second graph (scales to its values).
If I use
plot '< stuff.pl' u 2:3
replot '< stuff.pl' u 4:5
, which should behave the same imo, the scaling works.
I am not understanding this behaviour.
Upvotes: 2
Views: 108
Reputation: 48420
The replot
calls the previous plot
command and then adds another plot. In the previous plot command the variables haven't been replaced. When the replot
calls the previous plot command, the last values of xCol
and yCol
are used for both plots!
You can either use two different variables:
xCol1 = 2; yCol1 = 3
plot '< stuff.pl' u xCol1:yCol1
xCol2 = 4; yCol2 = 5
replot '< stuff.pl' u xCol2:yCol2
or you can use macros, which are replaced
set macros
cols='2:3'
plot '< stuff.pl' u @cols
cols='4:5'
replot '< stuff.pl' u @cols
Upvotes: 1