Reputation: 428
I want to use the iterative plot function plot for
in gnuplot for a parametric plot.
set parametric
f(x) = x
plot for [i=1:2] t,f(i*t)
However, as I learned in this Question, the for
iteration ends after a comma. So the iteration only applies to t
and not to f(i*t)
. But since a parametric plot needs a pair of functions separated by a comma, how can I tell gnuplot to iteratively plot my parametric plot?
Upvotes: 3
Views: 180
Reputation: 2332
Did you actually try it? gnuplot
distinguishes a comma between parametric coordinates and the end of a plot-element
as it is called (which can contain a for
-loop): this is simply done by counting the number of coordinates given.
E.g.,
set parametric
set size ratio -1
plot for [i=1:3] cos(t),i*sin(t) title "Ellipse ".i, \
for [i=1:3] i*cos(t),i*sin(t) title "Circle ".i
If you do
plot for [i=1:3] cos(t),i*sin(t),i*cos(t),i*sin(t)
then you keep the 3 ellipses (well, including the circle when i=1), and have one circle plotted for i=3
(the value i
kept after the for
loop) from the last pair of coordinates.
Upvotes: 2