|
From: Ethan M. <eam...@gm...> - 2022-09-15 20:37:59
|
On Thursday, 15 September 2022 11:06:44 PDT Geoff Kaniuk wrote:
> Dear gnuplot,
>
> I would like to plot a sequence of arrays.
>
> For example, I have a script:
>
> plot-arrays.gp
> # TEST PLOT ARRAYS
> reset session
>
> array ab1[3] = [ 1.1, 1.2, 1.3 ]
> array ab2[3] = [ 2.1, 2.2, 2.3 ]
>
> plot ab1 w lp, ab2 w lp
>
> abname(i)=sprintf("%s%d", "ab", i)
>
> do for [k=1:2]{ abk = abname(k); plot abk w lp }
> # END
>
> The first plot command works fine. But I have a large number of such
> arrays and would like to proceed as in the second looped command.
See "help eval".
You want something like this
do for [k=1:N] {
command = sprintf("plot ab%d w lp", k)
eval(command);
}
Ethan
|