plotiterationgnuplotparametric-equations

iteration and parametric mode with t ranging according to a function - gnuplot


I'm trying to iterate in parametric mode to plot several concentric arcs of circles with the parameter t ranging according to a function. I've tried, among others,

a=sqrt(2)
plot [-pi/2:pi/2] a*cos(t), a*sin(t)
do for [i=2:10] {
  a=sqrt(2)/i
  set trange [-1./2*acos(-(a**2)/2.):1./2*acos(-(a**2)/2.)]
  replot a*cos(t), a*sin(t)
}

what I see is a plot of 10 identical overlapped arcs. I also replaced replot with plot and only the last arc is retained.

I know "that iteration does not work for plots in parametric mode" (ref. "plot for" in the manual), but this is using a do for construct. There must be a way to do this! How?

System: gnuplot Version 5.2 patchlevel 2, windows 10.


Solution

  • Today I developed my own solution, which is

    a(i)=sqrt(2)/30*(31-i)
    s(t, i)=t*(1./2*acos(-(a(i)**2)/2.))/(pi/2)
    set trange [-pi/2:pi/2]
    plot [-pi/2:pi/2] for [j=1:30] a(j)*cos(s(t,j)), a(j)*sin(s(t,j)) lw 2
    

    Notice that in the meanwhile I made a little math adjustment from a=sqrt(2)/i to a(i)=sqrt(2)/30*(31-i).

    Output:

    arcs stopping at half lemniscate

    The settings used to output that picture are

    set term wxt size 800,800
    set grid
    set size ratio -1
    set parametric
    set xrange [-1.6:1.6]
    set yrange [-1.6:1.6]
    

    The rationale behind this is that in this way I set trange only once, and then with a variable substitution I map [0:pi/2] to [0:s(pi/2,i)].