I've just about completed a revamp of gretl's plotting
commands, with the hope of achieving greater consistency and
flexibility -- and in particular, of making it possible to
produce a greater variety of plots non-interactively. If
people can help with some testing, that would be great.
In explaining what I've done, I need to distinguish two sorts
of plotting commands. The first category I'll call "pure"
plotting commands: these all have as their sole purpose the
production of a plot of some kind. This category includes
gnuplot, boxplot, scatters, qqplot.
The second category contains commands that produce some
textual or tabular output, but also produce a plot (at least
under some conditions). This includes:
corrgm, xcorrgm, pergm, hurst, rmplot, leverage, fcast
(and possibly a few others, not yet considered in the
revamping).
So here's the first objective: all of the pure plotting
commands should support the --output=whatever option, and
should behave in the following way. If invoked in batch mode
(that is, via script) the default behaviour is to write an
auto-named gnuplot command file (gpttmp01.plt and so on), but
the --output option can be used to send the plot to a window
(with --output=display) or to a named file, the format of
which is governed by the filename suffix as follows;
.eps -> EPS (encapsulated postscript)
.pdf -> PDF
.png -> PNG
.fig -> Xfig
.emf -> EMF (MS Enhanced Metafile)
.svg -> SVG (Scalable Vector Graphics)
.plt -> named gnuplot command file
If a pure plotting command is invoked in interactive mode
(i.e. typing commands in the GUI gretl console, or using
gretlcli interactively), the default is for the plot to be
displayed in a window, but --output can be used to produce a
specified file instead, as above.
And here's the second objective: all other (non-pure) plotting
commands should have an option, --plot=whatever, which acts
much like the --output option above. The behaviour of these
commands should be as follows. If invoked in batch mode, by
default no plot is produced, but a plot (for display or to
file) can be provoked using --plot. In interactive mode the
plot is produced and sent to a window by default, but it can
be diverted to file using --plot, or suppressed via
--plot=none.
I've written "should" above, but I think this is now mostly
working. Here's a sample test script (which illustrates the
fact that the batch-mode options are also available inside
functions):
<hansl>
function void testplot (series y, list X)
string vname = argname(y)
if vname == ""
vname = "y"
else
series @vname = y
endif
gnuplot @vname --time-series --with-lines
gnuplot @vname --time-series --with-lines --output=display
gnuplot @vname --time-series --with-lines --output=ytime.pdf
boxplot @vname
boxplot @vname --output=display
boxplot @vname --output=ybox.pdf
qqplot @vname
qqplot @vname --output=display
qqplot @vname --output=yqq.pdf
scatters @vname ; X
scatters @vname ; X --output=display
scatters @vname ; X --output=scatters.pdf
end function
open data9-7.gdt
list X = 2 3 4 5
testplot(QNC, X)
</hansl>
And here are a couple of examples for some non-pure plotting
commands:
<hansl>
open AWM.gdt
corrgm CAN
corrgm CAN --plot=display
corrgm CAN --plot=corrgm.pdf
pergm CAN
pergm CAN --plot=display
pergm CAN --plot=pergm.pdf
xcorrgm CAN EEN
xcorrgm CAN EEN --plot=display
xcorrgm CAN EEN --plot=xcorrgm.pdf
</hansl>
<hansl>
open djclose.gdt
rmplot djclose
rmplot djclose --plot=display
rmplot djclose --plot=rmplot.pdf
y = ldiff(djclose)
hurst y
hurst y --plot=display
hurst y --plot=hurst.pdf
</hansl>
The help text for the relevant commands still needs to be
updated in many cases.
Allin