I'd like to plot at regular intervalls a file with gnuplot
instructions (say "foo.dem"), eventually with cron.
But the title of the plot should be dependant of external variables,
so it can't be specified in the .dem file. It could be for instance
the time at this moment.
And it could be interessant to save the plots in files with differents
names, dependant of such variables.
Is it possible to specify a string or any variable according to an
environment variable, or to pass it through an option ?
Thanks in advance,
Gauthier
> But the title of the plot should be dependant of external variables,
> so it can't be specified in the .dem file. It could be for instance
> the time at this moment.
Depending on what you particularly want, you could create an auxiliary
file "aux.gp" containing statements like
titlestring="yourtitle"
(and also define, of course, numerical variables uses in the plot,
accordingly) and load it into gnuplot by
load "aux.gp"
You can also convert numbers into strings via the sprintf function (it
actually uses a C printf statement to create a string; please see the
gnuplot help or gnuplot.pdf for more information) and concatenate
strings with
string3=string1.string2
or
string3="something"."somethingelse".sprintf(...)
etc.
> And it could be interessant to save the plots in files with differents
> names, dependant of such variables.
You can define the output file name (which is set by set output <name>)
using the strings created like shown above. Maybe there is another
method I am not aware of, but passing variables via a helper file gives
you a high degree of freedom.
HTH,
Ingo
accessing an environmental variable from inside gnuplot:
gnuplot> nextfile = system("echo $NEXTFILE")
gnuplot> set term png
gnuplot> set out nextfile . ".png"
gnuplot> plot nextfile ...
or if you prefer to do the substitution from the command line
before entering gnuplot:
gnuplot -e "file = $NEXTFILE" gnuplot_command_script.gp