Of 3 versions of replotting only 2 work as desired:
plot sin(x)
replot sin(x)/2
replot sin(x)/3
replot sin(x)/4
After each command the respective curve is added to the plot - as expected.
plot sin(x)
replot for [i=2:4] sin(x)/i
gives the same (final) result (4 curves in the plot), but
plot sin(x)
do for [i=2:4] {replot sin(x)/i}
results in a plot with only the 1st and the 4th curve, although 4 lines are written in the key. Is this a "feature" or (how) can I get 4 curves in the do-for-version (because I have to do some additional stuff within the do-clause)?
[gnuplot 5.2 (8), Ubuntu MATE 20.04]
plot for [i=1:4] sin(x)/i
. What else do you have to do inbetween why you need ado for
loop? – theozhsin(x)/4
will be on top of each other. If you typeshow plot
in the gnuplot console you will getlast plot command was: plot sin(x), sin(x)/i, sin(x)/i, sin(x)/i
and for the lastreplot
commandi=4
. I guess that's the wayreplot
works. It will not plotsin(x), sin(x)/2, sin(x)/3, sin(x)/4
. – theozhplot for [i=1:4] for [b=0:1] b?sin(x)/i:cos(x)/i title sprintf("%s(x)/%d",b?'sin':'cos',i)
. But maybe you edit the question and describe your final goal in more detail. – theozh