Allin,
On Thu, 9 Aug 2012, Paulo Grahl wrote:You should write a gretl function to do the job.
> I am trying to run a gnuplot script from within a gretl script. Where can I
> find some help / tutorials?
> Basically, I am trying to do the following:
> 1. run a gretl script that opens a data file (which is updated every month).
> 2. do some calculations and stats withing gretl script
> 3. create a gnuplot with a "professional look"
> 3.a - ideally I would have a standard gnuplot script (with some
> fancy formatting, with recession bars, etc) and then I would pass the
> variables to be plotted (and some strings that would be the names of those
> variables, title of the chart, etc) as parameters for the gnuplot script.
>
> The idea is to have a gnuplot script that would work as a "template" and
> then I would use this template to generate some charts with different time
> series.
Do you really need to write your own plot command from scratch, or
can you use gretl's "gnuplot" command plus {...} commands? The
latter would be considerably easier. But here's a trivial example of
the former.
<hansl>
function void write_plot_file (string fname, list ylist,
series x, string title)
outfile @fname --write
printf "set style line 1 lc rgb \"#ff0000\"\n"
printf "set style line 2 lc rgb \"#0000ff\"\n"
# and so on, if need be
printf "set title \"%s\"\n", title
print "plot \"
nv = nelem(ylist)
loop foreach i ylist -q
printf "'-' using 1:2 title \"%s\" w lines", varname(ylist[i])
if i < nv
printf " , \\\n"
else
printf "\n"
endif
endloop
loop foreach i ylist -q
loop t=1..$nobs -q
printf "%.10g %.10g\n", x[t], ylist.$i[t]
endloop
printf "e\n"
endloop
outfile --close
end function
# driver script
open data9-7
string fname = "myplot.gp"
string title = "My title"
list ylist = PRIME UNEMP
series x = 1975
x = x(-1) + 0.25
write_plot_file(fname, ylist, x, title)
gnuplot --input="@fname" --output=display
</hansl>
Allin Cottrell
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users