3

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?

2
  • 1
    I don't know, but here on Version 5.0 patchlevel 3 it seems to work Commented May 4, 2016 at 12:27
  • Unfortunately it does not work in gnuplot 4.6 Commented May 4, 2016 at 15:58

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Which gnuplot version do you use? I have gnuplot 4.6, and it seems not to work there.
I have gnuplot 5, but this also works with version 4.6 (patchlevel 6), it should work with versions >= 4.4. Please give detail on what "seems not to work". You should obtain 6 ellipses/circle in the first case (with ellipse 1 and circle 1 identical), 3 ellipses (1 being a circle) and 1 large circle (radius 3) in the second case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.