
5.5 Maxima: Beyond Preliminaries 203
plots x
2
and x
3
with styles 3 and 4 respectively. When printing on screen, these
styles are different colors, but may be converted to dotted or dashed lines, and the
like, when saved to file (the line-style depends on the format in which it is saved).
Replacing the style option above by [style,[points,3,4]]would plot
points rather than connected curves (which is rather pointless in this case, but
could be useful sometimes). Finally, [style,[linespoints]]would plot
points connected by lines. This latter option accepts numbers to modify size,
style, and color of the points and the lines. When two curves are plotted into
the same figure, then each may have its own set of options. To plot the first
one using lines and the second one using points one needs to specify the op-
tion [style,[lines],[points]]. Many other combinations are possible,
of course.
Plotting to file There is a very simple way to save the plot to file. The option
[psfile,“myFirstplot.ps”] within a plot2d command will save the
plot in a file called myFirstPlot.ps in Postscript format. On Mac OSX this
file can be opened by double-clicking on the file. On other platforms this may be
more involved and require additional programs. Users who are not comfortable
handling Postscript files are advised to use the Gnuplot options below to save the
output of a plot in a different format.
Readers who have their own favorite plotting program may be interested in the
maxout.gnuplot_pipes file. Whenever Maxima produces a plot it writes the
sample dots that will be used to plot the figure into this temporary file; most likely
this is located in the home directory of the user (at least on Mac OSX and Linux
systems). The points in this file can be used directly to generate the plots using
third-party software.
Since Maxima uses Gnuplot as the plotter, it is also possible to harness some of
the power of Gnuplot directly from within Maxima to produce high quality, highly
customized plots. This is particularly useful when there is a need to export the plot in
file formats other than the standard provided by plot2d. To do this it is necessary
to pass options directly to Gnuplot. The simplest option is designed for output to
terminals
19
with no graphics capabilities, as follows
plot2d(x^2,[x,1,2],[gnuplot_term,dumb],
[gnuplot_out_file,“art.txt”])
This will plot a pseudo-graphic using keyboard characters into the file art.txt.
It can be viewed using a text editor. Besides terminal-type dumb, there are a number
of other Gnuplot terminals. These include JPEG, Postscript, PNG, PDF and many
others. However, not all are installed by default on every system, hence some of the
commands might not work. We give a few examples of options to illustrate the pos-
sibilities. To save space, we will henceforth not repeat the gnuplot_out_file
option, but this must always be supplied to specify the output file.
[gnuplot_term, “png size 123 123”]
19
In its widest sense, “terminal” is best thought of as Gnuplot-jargon for file format.