I was trying to plot the following
plot for [h=0:2:0.1] sin(h*x)
But it gives the following error
gnuplot> plot for [h=0:2:0.1] sin(x*h)
^
Expecting iterator for [<var> = <start> : <end> {: <incr>}]
or for [<var> in "string of words"]
But the following line works just fine
plot for [h=0:2:1.1] sin(x*h)
Is this a bug or it is supposed to work this way? I mean, why it is not accepting increments smaller than 1?
I'm using the following version of gnuplot
G N U P L O T
Version 5.0 patchlevel 1 last modified 2015-06-07
Gnuplot supports iterations only with integer values (see documentation section "For loops in plot command", p 98). Values smaller then 1
are casted as integer to 0
, which is not allowed. Using e.g.
plot for [h=0:3:1.5] sin(x*h) title sprintf('%.1f', h)
plots four curves with h
having the values 0, 1, 2, 3
. To use smaller values you must scale the iteration value later:
plot for [h=0:20:1] sin(0.1*h*x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With