Using Version 5.2 patchlevel 2, I tried the following plot:
gnuplot> set xdata time
gnuplot> set timefmt "%s"
gnuplot> array lr_a[100];array lr_b[100]
gnuplot> plot "free.dat" using 2:(i=stringcolumn(0)+1,lr_a[i]=$13,lr_b[i]=$14,$10) with linesp title columnheader(1)
gnuplot> print i
13
gnuplot> print lr_a
[-452057.0,-178648.0,9568.53,10688.5,11016.6,11142.9,11137.5,12296.8,12467.0,-147009.0,-18170.2,-17176.1,-6493.16,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]
gnuplot> print lr_b
[0.000292381,0.000119527,5.32936e-07,-1.75101e-07,-3.82532e-07,-4.62388e-07,-4.58968e-07,-1.19192e-06,-1.29956e-06,9.95245e-05,1.80699e-05,1.74415e-05,1.06875e-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]
Now I want to add plots using those arrays:
j=1
gnuplot> replot "free.dat" using 2:(lr_a[j]+lr_b[j]*$2) with linesp title "LR#".j
It worked, however when I try to add more plots like this
gnuplot> j=j+1;replot "free.dat" using 2:(lr_a[j]+lr_b[j]*$2) with linesp title "LR#".j
gnuplot> j=j+1;replot "free.dat" using 2:(lr_a[j]+lr_b[j]*$2) with linesp title "LR#".j
gnuplot> print j
3
The plots are all the same, labeled LR#3
.
Why is that so?
For reference, here's (a rather useless) free.dat
:
/home 1581728983 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0 10411.5 0 1 10411.5
/home 1581729050 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00976562 -452057 0.000292381 1.00299 10411.5
/home 1581729142 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00920748 -178648 0.000119527 0.83085 10411.5
/home 1581730106 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00799351 9568.53 5.32936e-07 0.0304721 10411.5
/home 1581730231 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00715961 10688.5 -1.75101e-07 -0.0133904 10411.5
/home 1581730248 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00654339 11016.6 -3.82532e-07 -0.033421 10411.5
/home 1581730649 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00606222 11142.9 -4.62388e-07 -0.0487386 10411.5
/home 1581730988 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00567332 11137.5 -4.58968e-07 -0.0582907 10411.5
/home 1581732515 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00552427 12296.8 -1.19192e-06 -0.228729 10411.5
/home 1581732849 51175 51175 0 51175 0 1 51175 10411.5 10411.5 0.00537109 12467 -1.29956e-06 -0.30963 10411.5
/home 1581733526 51175 51175 0 51175 0 1 51175 10412.4 10411.6 0.258446 -147009 9.95245e-05 0.578522 10411.8
/home 1581797054 51175 51175 0 51175 0 1 51175 10412.7 10411.7 0.406035 -18170.2 1.80699e-05 0.818011 10412.8
/home 1581799764 51175 51175 0 51175 0 1 51175 10412.7 10411.7 0.482222 -17176.1 1.74415e-05 0.884514 10412.8
/home 1581802740 51175 51175 0 51175 0 1 51175 10411.5 10411.7 0.469488 -6493.16 1.06875e-05 0.646611 10412.3
replot
does not act as you may think it does. It does not reproduce the previous plot; it creates a new plot by re-using the previous command. So the sequence of commands
j = j0
plot foo(j)
j = j+1
replot, foo(j)
j = j+1
replot, foo(j)
results in 3 copies of the same plot foo(j0+2)
If you want to compose a plot with successive values of k do not use replot
. Instead do something like
plot for [j = j0 : j0+2] foo(j)