System variable
plot_options
Elements of this list state the default options for plotting.
If an option is present in a plot2d
or plot3d
call,
that value takes precedence over the default option.
Otherwise, the value in plot_options
is used.
Default options are assigned by set_plot_option
.
Each element of plot_options
is a list of two or more items.
The first item is the name of an option, and the remainder comprises the value or values
assigned to the option.
In some cases the, the assigned value is a list, which may comprise several items.
The plot options which are recognized by plot2d
and plot3d
are the following:
Option: plot_format
Determines which graphic interface is used by plot2d
and
plot3d
.
Value: gnuplot
default on Windows
Gnuplot is the most advanced plotting package among the packages available in Maxima. It requires an external gnuplot installation.
Value: gnuplot_pipes
default on non-Windows platforms
Similar to the gnuplot
format except that communication with
gnuplot is done through a pipe. It should be used to plot on screen,
for plotting to files it is better to use the gnuplot
format.
Value: mgnuplot
Mgnuplot is a Tk-based wrapper around gnuplot. It is included in the Maxima distribution. Mgnuplot offers a rudimentary GUI for gnuplot, but has fewer overall features than the plain gnuplot interface. Mgnuplot requires an external gnuplot installation and Tcl/Tk.
Value: openmath
Openmath is a Tcl/Tk GUI plotting program. This format is provided by Xmaxima, which is distributed together with Maxima; in order to use this format you should install the package Xmaxima, and it will work not only from Xmaxima itself, but also from the command line and other GUI's for Maxima.
Option: run_viewer
Controls whether or not the appropriate viewer for the plot format should be run.
Default value: true
Execute the viewer program.
Value: false
Do not execute the viewer program.
Option: y
The vertical range of the plot.
Example:
[y, - 3, 3]
Sets the vertical range to [-3, 3].
Option: plot_realpart
When plot_realpart
is true
,
the real part of a complex value x is plotted;
this is equivalent to plotting realpart(x)
instead of x.
Otherwise,
only values with imaginary part equal to 0 are plotted,
and complex values are ignored.
Example:
plot2d (log(x), [x, -5, 5], [plot_realpart, false]); plot2d (log(x), [x, -5, 5], [plot_realpart, true]);
The default value is false
.
Option: nticks
In plot2d, it is gives the initial number of points used by the adaptive plotting routine for plotting functions. It is also the number of points that will be shown in a parametric plot.
Example:
[nticks, 20]
The default for nticks
is 10.
Option: adapt_depth
The maximum number of splittings used by the adaptive plotting routine.
Example:
[adapt_depth, 5]
The default for adapt_depth
is 10.
Option: xlabel
The label for the horizontal axis in a 2d plot.
Example:
[xlabel, "Time in seconds"]
Option: ylabel
The label of the vertical axis in a 2d plot.
Example:
[ylabel, "Temperature"]
Option: logx
It makes the horizontal axis of a 2d plot to be rendered in a logarithmic scale. It does not need any aditional parameters.
Option: logy
It makes the vertical axis of a 2d plot to be rendered in a logarithmic scale. It does not need any aditional parameters.
Option: legend
The labels for the various expressions in a 2d plot with several expressions. If there are more expressions than the number of labels given, they will be repeated. By default, the names of the expressions or functions will be used, or the words discrete1, discrete2, ..., for discrete sets of points.
Example:
[legend, "Set 1", "Set 2", "Set 3"]
Option: style
The styles that will be used for the various functions or sets of data in a 2d plot. The word style must be followed by one or more styles. If there are more functions and data sets than the styles given, the styles will be repeated. Each style can be either lines for line segments, points for isolated points, linespoints for segments and points, or dots for small isolated dots. Gnuplot accepts also an impulses style.
Each of the styles can be enclosed inside a list with some aditional parameters. lines accepts one or two numbers: the width of the line and an integer that identifies a color. points accepts one or two parameters; the first parameter is the radius of the points and the second parameter is an integer that in Gnuplot selects different shapes and colors for the points and in Openmath changes the color used for the points. linesdots accepts up to four parameters; the first two are the same as for lines and the last two are the same as for points.
Example:
[style,[lines,2,3],[points,1,4]]
In Gnuplot, this will plot the first (and third, fifth, etc) expression with blue line segments of width 2, and the second (and fourth, sixth, etc) expression with green squares of size 1. In Openmath, the first expression will be plotted with magenta lines of width 2, and the second with orange points of radius 1; notice that openmath_color(3) and openmath_color(4) return ``magenta'' and ``orange''.
The default for the style option is lines with a width of 1, and different colors.
Option: grid
Sets the number of grid points to use in the x- and y-directions for three-dimensional plotting.
Example:
[grid, 50, 50]
sets the grid to 50 by 50 points. The default grid is 30 by 30.
Option: transform_xy
Allows transformations to be applied to three-dimensional plots.
Example:
[transform_xy, false]
The default transform_xy
is false
. If it is not false
, it should be
the output of
make_transform([x,y,z], f1(x,y,z), f2(x,y,z), f3(x,y,z))$
The polar_xy
transformation is built in. It gives the same
transformation as
Gnuplot options:
There are several plot options specific to gnuplot. Some of these options are raw gnuplot commands, specified as strings. Refer to the gnuplot documentation for more details.
Option: gnuplot_term
Sets the output terminal type for gnuplot.
Default value: default
Gnuplot output is displayed in a separate graphical window.
Value: dumb
Gnuplot output is displayed in the Maxima console by an "ASCII art" approximation to graphics.
Value: ps
Gnuplot generates commands in the PostScript page description language.
If the option
gnuplot_out_file
is set to filename, gnuplot writes the PostScript commands to filename.
Otherwise, it is saved as maxplot.ps
file.
Value: any other valid gnuplot term specification
Gnuplot can generate output in many other graphical formats such
as png, jpeg, svg etc. To create plot in all these formats the
gnuplot_term
can be set to any supported gnuplot term name (symbol)
or even full gnuplot term specification with any valid options (string).
For example [gnuplot_term,png]
creates output in PNG (Portable
Network Graphics) format while [gnuplot_term,"png size 1000,1000"]
creates PNG of 1000x1000 pixels size.
If the option gnuplot_out_file
is set to filename, gnuplot
writes the output to filename. Otherwise, it is saved as
maxplot.term
file, where term is gnuplot
terminal name.
Option: gnuplot_out_file
Write gnuplot output to a file.
Default value: false
No output file specified.
Value: filename
Example: [gnuplot_out_file, "myplot.ps"]
This example sends PostScript output to the file myplot.ps
when
used in conjunction with the PostScript gnuplot terminal.
Option: gnuplot_pm3d
Controls the usage PM3D mode, which has advanced 3D
features. PM3D is only available in gnuplot versions after 3.7. The
default value for gnuplot_pm3d
is false
.
Example:
[gnuplot_pm3d, true]
Option: gnuplot_preamble
Inserts gnuplot commands before the plot is
drawn. Any valid gnuplot commands may be used. Multiple commands
should be separated with a semi-colon. The example shown produces a
log scale plot. The default value for gnuplot_preamble
is the empty string ""
.
Example:
[gnuplot_preamble, "set log y"]
Option: gnuplot_curve_titles
Controls the titles given in the plot key. The
default value is [default]
, which automatically sets the title of each
curve to the function plotted. If not [default]
, gnuplot_curve_titles
should contain a list of strings,
each of which is "title 'title_string'"
.
(To disable the plot key, add "set nokey"
to gnuplot_preamble
.)
Example:
[gnuplot_curve_titles, ["title 'My first function'", "title 'My second function'"]]
Option: gnuplot_curve_styles
A list of strings controlling the appearance
of curves, i.e., color, width, dashing, etc., to be sent to the
gnuplot plot command. The default value is
["with lines 3", "with lines 1", "with lines 2", "with lines 5", "with lines 4", "with lines 6", "with lines 7"]
, which cycles through different colors. See the
gnuplot documentation for plot
for more information.
Example:
[gnuplot_curve_styles, ["with lines 7", "with lines 2"]]
Option: gnuplot_default_term_command
The gnuplot command to set the
terminal type for the default terminal. The default value is setterm windows "Verdana" 15
in Windows systems, and set term x11font "Helvetica,16"
in X11 windows systems.
Example:
[gnuplot_default_term_command, "set term x11"]
Option: gnuplot_dumb_term_command
The gnuplot command to set the
terminal type for the dumb terminal. The default value is "set term dumb 79 22"
,
which makes the text output 79 characters by 22
characters.
Example:
[gnuplot_dumb_term_command, "set term dumb 132 50"]
Option: gnuplot_ps_term_command
The gnuplot command to set the terminal
type for the PostScript terminal. The default value is
"set size 1.5, 1.5;set term postscript eps enhanced color solid 24"
,
which sets the
size to 1.5 times gnuplot's default, and the font size to 24, among
other things. See the gnuplot documentation for set term postscript
for more information.
Example:
All the figures in the examples for the plot2d function in this
manual were obtained from Postscript files that were generated after
setting gnuplot_ps_term_command
as:
[gnuplot_ps_term_command, "set size 1.3, 1.3; \ set term postscript eps color solid lw 2.5 30"]
Examples:
Saves a plot of sin(x)
to the file sin.eps
.
Uses the y option to chop off singularities and the gnuplot_preamble option to put the key at the bottom of the plot instead of the top.
(%i2) plot2d ([gamma(x), 1/gamma(x)], [x, -4.5, 5], [y, -10, 10], [gnuplot_preamble, "set key bottom"])$
Uses a very complicated gnuplot_preamble
to produce fancy x-axis labels.
(Note that the gnuplot_preamble
string must be entered without any line breaks.)
(%i3) my_preamble: "set xzeroaxis; set xtics ('-2pi' -6.283, \ '-3pi/2' -4.712, '-pi' -3.1415, '-pi/2' -1.5708, '0' 0, \ 'pi/2' 1.5708, 'pi' 3.1415,'3pi/2' 4.712, '2pi' 6.283)"$ (%i4) plot2d([cos(x), sin(x), tan(x), cot(x)], [x, -2*%pi, 2.1*%pi], [y, -2, 2], [gnuplot_preamble, my_preamble]);
Uses a very complicated gnuplot_preamble
to produce fancy x-axis labels,
and produces PostScript
output that takes advantage of the advanced text formatting available
in gnuplot.
(Note that the gnuplot_preamble
string must be entered without any line breaks.)
(%i5) my_preamble: "set xzeroaxis; set xtics ('-2{/Symbol p}' \ -6.283, '-3{/Symbol p}/2' -4.712, '-{/Symbol p}' -3.1415, \ '-{/Symbol p}/2' -1.5708, '0' 0,'{/Symbol p}/2' 1.5708, \ '{/Symbol p}' 3.1415,'3{/Symbol p}/2' 4.712, '2{/Symbol p}' \ 6.283)"$ (%i6) plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi], [y, -2, 2], [gnuplot_preamble, my_preamble], [gnuplot_term, ps], [gnuplot_out_file, "trig.eps"]);
A three-dimensional plot using the gnuplot pm3d terminal.
A three-dimensional plot without a mesh and with contours projected on the bottom plane.
(%i8) my_preamble: "set pm3d at s;unset surface;set contour;\ set cntrparam levels 20;unset key"$ (%i9) plot3d(atan(-x^2 + y^3/4), [x, -4, 4], [y, -4, 4], [grid, 50, 50], [gnuplot_pm3d, true], [gnuplot_preamble, my_preamble])$
A plot where the z-axis is represented by color only.
(Note that the gnuplot_preamble
string must be entered without any line breaks.)
(%i10) plot3d (cos (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4], [gnuplot_preamble, "set view map; unset surface"], [gnuplot_pm3d, true], [grid, 150, 150])$