|
From: Bastian M. <bma...@we...> - 2009-05-22 18:14:39
|
There's also a patch on sourceforge which implements general scripting
support with a language called Rexx.
(This had been only available on OS/2 previously).
In your case you could use the word() function and reread as follows,
though:
In a file called sth. like main.gp do:
# we use a string to simulate an array
filenumbers = "0.01 0.1 1 2 3 10"
# initialize loop counter
index = 1
# start loop
load "loop.gp"
In loop.gp then do:
# use filenumbers string as array
i = word(filenumbers, index)
# construct a new data pipe command
command=sprintf("< ./script %s", i)
filename=sprintf("name-%s.png", i)
set output filename
plot command using 1:3 with lines
# increase loop counter
index = index + 1
# iterate
if (index <= words(filenumbers)) reread
Not sure the above stuff is free of errors - I did not test it. But you
should get the idea for the looping bit... :)
I have not used strings with pipe commands before (the "< ./script" bit)
so no guarantee that the plot command actually works.
Bastian
Mojca Miklavec schrieb:
> 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
>
> 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.
>
> Thanks,
> Mojca
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> gnuplot-beta mailing list
> gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
>
|