|
From: Juergen W. <wie...@fr...> - 2009-05-22 14:27:35
|
Hello,
> Is there some way to do something like this in gnuplot apart from
> using external script?
>
> for [i in "0.01 0.1 1 2 3 10"]
> filename=sprintf("name-%g.png", i)
> command=sprintf("./script %g", i)
> set output filename
> plot command using 1:3 with lines
> endfor
There is a patch at sourceforge (2652184):
https://sourceforge.net/tracker/?func=detail&aid=2652184&group_id=2055&atid=302055
It allows something like:
for [str in "0.01 0.1 1 2 3 10"] {
i = real(str)
filename=sprintf("name-%g.png", i)
command=sprintf("./script %g", i)
set output filename
plot command using 1:3 with lines
}
I haven't had too much feedback, though.
> I've read about reread, but I don't know how to apply it here except
> if gnuplot supports some array data structure which I think it doesn't
> (but maybe I'm wrong), or if I create a function with a long series of
> f(x) = (x==1) ? 0.01 : (x==2) ? 0.1 : (x==3) ? 1 ...
> but in that case I would probably prefer to use external script for that.
Well, something like (untested):
if (!exists('values')) values = "0.01 0.1 1 2 3 10"
if (!exists('i')) i = 1; else i = i + 1
val = real(word(values, i))
filename=sprintf("name-%g.png", val)
command=sprintf("./script %g", val)
set output filename
plot command using 1:3 with lines
if (i < words(values)) reread
Would probably also work.
Juergen
|