This follows on from the discussion initiated by Jack in
http://lists.wfu.edu/pipermail/gretl-devel/2014-September/005285.html
("Request for Comments: gnuplot and foreign").
In CVS and snapshots we now have a block-type command named "plot", ready
for testing and further comment. It has the following characteristics:
* The block starts with "plot" followed by a required parameter: the name
of a list, a single series or a matrix. This parameter specifies the data
to be plotted. The starting line may be prefixed with the "savename <- "
apparatus to save a plot as an icon in the GUI program.
* The block ends with "end plot".
* Inside the block you have zero or more lines of these types, identified
by an initial keyword:
- "option": specify a single option (details below)
- "options": specify multiple options on a single line
- "literal": a command to be passed to gnuplot literally
- "printf": a printf statement whose result will be passed
to gnuplot literally
The options available are basically those of the current "gnuplot"
command, but with a few differences. For one thing you don't need the
leading double-dash in an "option" (or "options") line. Besides that,
* You can't use the option --matrix=whatever with "plot": that possibility
is handled by providing the name of a matrix on the initial "plot" line.
* The --input=filename option is not supported: use "gnuplot" for the
case where you're supplying the entire plot specification yourself.
* the several options linear-fit, quadratic-fit, suppress-fitted, etc.,
pertaining to the presence and type of a fitted line, are replaced in
"plot" by a single option "fit" which requires a parameter. Supported
values for the parameter are: none, linear, quadratic, cubic, inverse,
semilog and loess. Example:
option fit=quadratic
As with "gnuplot" the default is to show a linear fit in an X-Y scatter if
it's significant at the 10 percent level.
If more than one option is given on a line, the options should be
separated by spaces.
The "printf" facility allows the use of string variables without having to
resort to "@"-style string substitution.
Here's a simple example, the plot spec from the "bandplot" package, in
"before" and "after" forms:
<hansl mode="old">
gnuplot 1 2 3 4 --with-lines --matrix=plotmat \
--suppress-fitted --output=display \
{ set linetype 3 lc rgb "#0000ff"; set title "@title"; \
set nokey; set xlabel "@xname"; }
</hansl>
<hansl mode="new">
plot plotmat
options with-lines fit=none
literal set linetype 3 lc rgb "#0000ff"
literal set nokey
printf "set title \"%s\"", title
printf "set xlabel \"%s\"", xname
end plot --output=display
</hansl>
Note that --output=display is appended to "end plot": this option could be
"inlined" like the others but IMO it has a different status and I favour
the idiom of placing it outside the block.
Also note that if you give a matrix to "plot" it's assumed you want to
plot all the columns. In addition, if you give a single series and the
dataset is time series, it's assumed you want a time-series plot.
Nothing is "set in stone" at this point and comments are welcome. I can
think of various possible extensions of this approach myself, but I
thought the first task was to put something in place which basically
covers the functionality of the "gnuplot" command but in a cleaner and
less clotted fashion.
Allin