[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8.1 Introduction to Plotting | ||
8.2 Functions and Variables for Plotting |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Maxima uses an external plotting package to make the plots (see the
section on Plotting Interfaces below). Maxima calculates set of points
to be plotted and pass the to the plotting package together with a set
of commands; the commands and plot data are passed to the external
program either through a pipe or by saving them into a file with the
extension maxout.interface
, where interface
is the name of
the plotting interface being used.
The maxout.interface
file, in the cases when it is used, is
created in the directory specified by the variable temp_dir. That
location can be changed; by assigning to that variable a string that
represents a valid directory where Maxima can create new files.
After a plot has been obtained, the file maxout.interface
can be
executed again with the appropriate external program. If a Maxima plotting
command fails to show anything, that file can be inspected to look for
possible sources of problems.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Currently, Maxima can one of two external plotting programs: Gnuplot or
Xmaxima. There are various different interfaces for those programs,
which can be selected with the option [plot_format,interface]
,
where interface
is one of the following:
gnuplot
default on Windows
Gnuplot is the most advanced plotting package among the packages
available in Maxima. It requires an external gnuplot installation. All
plotting commands and data are passed in a file maxout.gnuplot
.
gnuplot_pipes
default on non-Windows platforms
Similar to the gnuplot
format except that the commands are sent
to gnuplot is done through a pipe; the data is passed via a file
maxout.gnuplot_pipes
. It should be used to plot on screen, for
plotting to files it is better to use the gnuplot
format.
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.
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. If it is used from within Xmaxima, all commands and data are
passed using the same socket used for the communication between Maxima
and Xmaxima. If it is used from the console or other interface different
from Xmaxima, the commands and data will be save in a file named
maxout.openmath
.
@ref{Category: Plotting}
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Plots the contours (curves of equal value) of expr
over the region x_range by y_range.
Any additional arguments are treated the same as in plot3d
.
contour_plot
only works when the plot format is gnuplot
or gnuplot_pipes
.
See also implicit_plot
.
Examples:
(%i1) contour_plot (x^2 + y^2, [x, -4, 4], [y, -4, 4]); (%o1) (%i2) contour_plot (sin(y) * cos(x)^2, [x, -4, 4], [y, -4, 4]); (%o2) (%i3) F(x, y) := x^3 + y^2; 3 2 (%o3) F(x, y) := x + y (%i4) contour_plot (F, [u, -4, 4], [v, -4, 4]); (%o4) (%i5) contour_plot (F, [u, -4, 4], [v, -4, 4], [gnuplot_preamble, "set size ratio -1"]); (%o5) (%i6) set_plot_option ([gnuplot_preamble, "set cntrparam levels 12"])$ (%i7) contour_plot (F, [u, -4, 4], [v, -4, 4]);
@ref{Category: Plotting}
Default value: false
When in_netmath
is true
,
plot3d
prints OpenMath output to the console if plot_format
is openmath
;
otherwise in_netmath
(even if true
) has no effect.
in_netmath
has no effect on plot2d
.
Where expr, expr_1, ..., expr_n can be either
expressions, or Maxima or Lisp functions or operators, or a list with
the any of the forms: [discrete, [x1, ..., xn],
[y1, ..., yn]]
, [discrete, [[x1, y1],
..., [xn, ..., yn]]
or [parametric, x_expr,
y_expr, t_range]
.
Displays a plot of one or more expressions as a function of one variable.
plot2d
plots one expression expr or several expressions
[name_1, ..., name_n]
. The expressions that are not
of the parametic or discrete types should all depend only on one
variable var and it will be mandatory the use of x_range to
name that variable and gives its minimum and maximum values, using the
syntax: [variable, min, max]
. The plot will
show the horizontal axis bound by the values of min and max.
A expression to be plotted can also be given in the discrete or
parametric forms. Namely, as a list starting with the word "discrete"
or "parametric". The keyword discrete must be followed by two
lists of values, both with the same length, which are the horizontal and
vertical coordinates of a set of points; alternatively, the coordinates
of each point can be put into a list with two values, and all the
coordinates of the points should be inside another list. The keyword
parametric must be followed by two expressions x_expr and
y_expr, and a range of the form [param, min,
max]
. The two expressions must depend only on the parameter
param, and the plot will show the path traced out by the point
with coordinates (x_expr, y_expr) as param increases
from min to max.
The range of the vertical axis is not mandatory. It is one more of the
options for the command, with the syntax: [y, min,
max]
. If that option is used, the plot will show that entire
range, even if the expressions do not reach all that range. Otherwise,
if a vertical range is not specified by set_plot_option
, the
boundaries of the vertical axis will be set up automatically.
All other options should also be lists, starting with the name of the option. The option xlabel can be used to give a label for the horizontal axis; if that option is not used, the horizontal axis will be labeled with the name of the variable specified in x_range, or with the expression x_expr in the case of just one parametric expression, or it will be left blank otherwise.
A label for the vertical axis can be given with the ylabel option. If there is only one expression to be plotted and the ylabel option was not used, the vertical axis will be labeled with that expression, unless it is too large, or with the expression y_expr if the expression is parametric, or with the text "discrete data" if the expression is discrete.
The options [logx]
and [logy]
do not need any
parameters. They will make the horizontal and vertical axes be
scaled logarithmically.
If there are several expressions to be plotted, a legend will be written to identiy each of the expressions. The labels that should be used in that legend can be given with the option legend. If that option is not used, Maxima will create labels from the expressions.
By default, the expressions are plotted as a set of line segments joining adjacent points within a set of points which is either given in the discrete form, or calculated automatically from the expression given, using an algorithm that automatically adapts the steps among points using as an initial estimate of the total number of points the value set with the nticks option. The option style can be used to make one of the expressions to be represented as a set of isolated points, or as points and line segments.
There are several global options stored in the list plot_options
which can be modified with the function set_plot_option
; any of
those global options can be overriden with options given in the
plot2d command. There are also other options which are not part of
the global options array plot_options and which can be given only
as part of the plot2d command; those options are: logx,
logy, box, legend, xlabel, ylabel,
psfile and style.
A function to be plotted may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression. If specified as a name or a lambda expression, the function must be a function of one argument.
Examples:
Plots of common functions.
(%i1) plot2d (sin(x), [x, -5, 5])$ (%i2) plot2d (sec(x), [x, -2, 2], [y, -20, 20], [nticks, 200])$
Plotting functions by name.
(%i3) F(x) := x^2 $ (%i4) :lisp (defun |$g| (x) (m* x x x)) $g (%i5) H(x) := if x < 0 then x^4 - 1 else 1 - x^5 $ (%i6) plot2d (F, [u, -1, 1])$ (%i7) plot2d ([F, G, H], [u, -1, 1], [y, -1.5, 1.5])$
We can plot a circle using a parametric plot with a parameter t. It is not necessary to give a range for the horizontal range, since the range of the parameter t determines the domain. However, since the graph's horizontal and vertical axes lengths are in the 4 to 3 proportion, we will use the xrange option to obtain the same scaling in both axes:
(%i8) plot2d ([parametric, cos(t), sin(t), [t,-%pi,%pi], [nticks,80]], [x, -4/3, 4/3])$
If we repeat that plot with only 8 points and extending the range of the parameter to give two turns, we will obtain the plot of a star:
(%i9) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2], [nticks, 8]], [x, -2, 2], [y, -1.5, 1.5])$
Combination of an ordinary plot of a cubic polynomial with a parametric plot of a circle:
(%i10) plot2d ([x^3+2, [parametric, cos(t), sin(t), [t, -5, 5], [nticks, 80]]], [x, -3, 3])$
Example of a logarithmic plot:
(%i11) plot2d (exp(3*s), [s, -2, 2], [logy])$
To show some examples of discrete plots, we will start by entering the coordinates of 5 points, in the two different ways that can be used:
(%i12) xx:[10, 20, 30, 40, 50]$ (%i13) yy:[.6, .9, 1.1, 1.3, 1.4]$ (%i14) xy:[[10,.6], [20,.9], [30,1.1], [40,1.3], [50,1.4]]$
To plot those data points, joined with line segments, we use:
(%i15) plot2d([discrete,xx,yy])$
We will now show the plot with only points, and illustrating the use of the second way of giving the points coordinates:
(%i16) plot2d([discrete, xy], [style, points])$
The plot of the data points can be shown together with a plot of the theoretical function that predicts the data:
(%i17) plot2d([[discrete,xy], 2*%pi*sqrt(l/980)], [l,0,50], [style, [points,5,2,6], [lines,1,1]], [legend,"experiment","theory"], [xlabel,"pendulum's length (cm)"], [ylabel,"period (s)"])$
The meaning of the three numbers after the "points" style option are as follows; 5: radius of the points, 2: index of color used (red), 6: type of objects used (solid squares). The two numbers after the "lines" style option give the thickness of the line (1 point) and the color (1 corresponds to blue).
To save a plot of sin(x)
to the file sin.ps
, one can use:
(%i18) plot2d (sin(x), [x, 0, 2*%pi], [psfile, "sin.eps"])$
The next example 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.
(%i19) plot2d ([gamma(x), 1/gamma(x)], [x, -4.5, 5], [y, -10, 10], [gnuplot_preamble, "set key bottom"])$
We can also use a gnuplot_preamble
to produce fancy x-axis
labels. (Note that the gnuplot_preamble
string must be entered
without any line breaks.)
(%i20) my_preamble: "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)"$ (%i21) plot2d([cos(x), sin(x), tan(x), cot(x)], [x, -2*%pi, 2.1*%pi], [y, -2, 2], [axes, x] [gnuplot_preamble, my_preamble]);
This example uses a 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.)
(%i22) my_preamble: "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)"$ (%i23) plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi], [y, -2, 2], [gnuplot_preamble, my_preamble], [psfile, "trig.eps"]);
See also plot_options
, which describes plotting options.
@ref{Category: Plotting}
graphs the list of `point sets' given in list by using xgraph. If the program xgraph is not installed, this command will fail.
A point set may be of the form
[x0, y0, x1, y1, x2, y2, ...]
or
[[x0, y0], [x1, y1], ...]
A point set may also contain symbols which give labels or other information.
xgraph_curves ([pt_set1, pt_set2, pt_set3]);
graph the three point sets as three curves.
pt_set: append (["NoLines: True", "LargePixels: true"], [x0, y0, x1, y1, ...]);
would make the point set (and subsequent ones), have no lines between points, and to use large pixels. See the man page on xgraph for more options to specify.
pt_set: append ([concat ("\"", "x^2+y")], [x0, y0, x1, y1, ...]);
would make there be a "label" of "x^2+y" for this particular
point set. The "
at the beginning is what tells
xgraph this is a label.
pt_set: append ([concat ("TitleText: Sample Data")], [x0, ...])$
would make the main title of the plot be "Sample Data" instead of "Maxima Plot".
To make a bar graph with bars which are 0.2 units wide, and to plot two possibly different such bar graphs:
(%i1) xgraph_curves ([append (["BarGraph: true", "NoLines: true", "BarWidth: .2"], create_list ([i - .2, i^2], i, 1, 3)), append (["BarGraph: true", "NoLines: true", "BarWidth: .2"], create_list ([i + .2, .7*i^2], i, 1, 3))]);
A temporary file `xgraph-out' is used.
@ref{Category: Plotting}
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
. There are other
local options specific to each plotting command, and not included in
this list of global options.
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:
plot_format
Determines which graphic interface is used by plot2d
and
plot3d
. It can be either gnuplot
, gnuplot_pipes
,
mgnuplot
or openmath
run_viewer
Controls whether or not the appropriate viewer for the plot format should be run.
true
Execute the viewer program.
false
Do not execute the viewer program.
y
The vertical range of the plot.
Example:
[y, - 3, 3]
Sets the vertical range to [-3, 3].
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
.
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.
adapt_depth
The maximum number of splittings used by the adaptive plotting routine.
Example:
[adapt_depth, 5]
The default for adapt_depth
is 10.
xlabel
The label for the horizontal axis in a 2d plot.
Example:
[xlabel, "Time in seconds"]
ylabel
The label of the vertical axis in a 2d plot.
Example:
[ylabel, "Temperature"]
logx
It makes the horizontal axis of a 2d plot to be rendered in a logarithmic scale. It does not need any aditional parameters.
logy
It makes the vertical axis of a 2d plot to be rendered in a logarithmic scale. It does not need any aditional parameters.
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. If legend is followed by the word false, no legend will be shown. 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"]
box
Currently, this option can only be followed by the word false, and it will be used to supress the box around the plot.
Example:
[box, false]
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. The default color codes are: 1: blue, 2: red, 3: magenta, 4: orange, 5: brown, 6: lime and 7: aqua. If you use Gnuplot with a terminal different than X11, those colors might be different; for example, if you use the option [gnuplot_term,ps], color index 4 will correspond to black, instead of orange.
points accepts one two or three parameters; the first parameter is the radius of the points, the second parameter is an integer that selects the color, using the same code used for lines and the third parameter is currently used only by Gnuplot and it corresponds to several objects instead of points. The default types of objects are: 1: filled circles, 2: open circles, 3: plus signs, 4: x, 5: *, 6: filled squares, 7: open squares, 8: filled triangles, 9: open triangles, 10: filled inverted triangles, 11: open inverted triangles, 12: filled lozenges and 13: open lozenges.
linesdots accepts up to four parameters: line width, points radius, color and type of object to replace the points.
Example:
[style,[lines,2,3],[points,1,4,3]]
This will plot the first (and third, fifth, etc) expression with magenta line segments of width 2, and the second (and fourth, sixth, etc) expression with orange plus signs of size 1 (orange circles in the case of Openmath).
The default for the style option is lines with a width of 1, and different colors.
psfile
This option is used to save the plots created by plot2d or plot3d into a Postscript file. The option should be given one parameter, which must be a valid name for a Postscript file. By default, that file will be created in the directory defined by the variable maxima_tempdir; the value of that variable can be changed to save the file in a different directory.
Example:
[psfile, "plot1.ps"]
axes
This is a global option used only by plot2d. By default it has the value true, which means that the two axis, x and y, will be displayed. It can be changed to x, to show only the x axis, or to y, which will show only the y axis, or to false to skip the display of the axes.
Example:
[axes, 'x]
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.
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
make_transform ([r, th, z], r*cos(th), r*sin(th), z)$
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. In most cases, these options can be replaced by one of the more general options above; in those cases we recommend that you use the most general form.
gnuplot_term
Sets the output terminal type for gnuplot.
default
Gnuplot output is displayed in a separate graphical window.
dumb
Gnuplot output is displayed in the Maxima console by an "ASCII art" approximation to graphics.
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.
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.
gnuplot_out_file
When used in conjunction with the gnuplot_term
option, it can be
used to save the plot in a file, in one of the graphic formats supported
by Gnuplot. If you want to create a Postscript file, you can use the
option psfile
instead, which will also work in Openmath, and does
the same thing with just one option.
[gnuplot_term, png], [gnuplot_outfile, "graph3.png"]
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]
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 size ratio -1"]
gnuplot_curve_titles
This is an old option that has been replaced by legend described above.
gnuplot_curve_styles
This is an old option that has been replaced by style described above.
gnuplot_default_term_command
The gnuplot command to set the
terminal type for the default terminal. The default value is set
term windows "Verdana" 15
in Windows systems, and set term x11
font "Helvetica,16"
in X11 windows systems.
Example:
[gnuplot_default_term_command, "set term x11"]
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"]
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"]
@ref{Category: Plotting}
Displays a plot of one or three expressions as functions of two variables.
(%i1) plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2]);
plots z = 2^(-u^2+v^2)
with u
and v
varying in [-3,3] and
[-2,2] respectively, and with u on the x axis, and v
on the y
axis.
The same graph can be plotted using openmath (if Xmaxima is installed):
(%i2) plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2], [plot_format, openmath]);
in this case the mouse can be used to rotate the plot to look at the surface from different sides.
An example of the third pattern of arguments is
(%i3) plot3d ([cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)), y*sin(x/2)], [x, -%pi, %pi], [y, -1, 1], ['grid, 50, 15]);
which plots a Moebius band, parametrized by the three expressions given
as the first argument to plot3d
. An additional optional argument
['grid, 50, 15]
gives the grid number of rectangles in the x direction and
y direction.
The function to be plotted
may be specified as the name of a Maxima or Lisp function or operator,
a Maxima lambda expression, or a general Maxima expression.
In the form plot3d (f, ...)
where f is the
name of a function or a lambda expression,
the function must be a function of two arguments.
In the form plot3d ([f_1, f_2, f_3], ...)
where f_1, f_2, and f_3 are names of functions or lambda expressions,
each function must be a function of three arguments.
This example shows a plot of the real part of z^1/3
, using polar
coordinates. The options box
and legend
were also used to
suppress the title and the axes box.
(%i4) plot3d (r^.33*cos(th/3), [r, 0, 1], [th, 0, 6*%pi], ['grid, 12, 80], ['transform_xy, polar_to_xy], [box, false],[legend,false]);
Other examples are the Klein bottle:
(%i5) expr_1: 5*cos(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y) + 3.0) - 10.0$ (%i6) expr_2: -5*sin(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y) + 3.0)$ (%i7) expr_3: 5*(-sin(x/2)*cos(y) + cos(x/2)*sin(2*y))$ (%i8) plot3d ([expr_1, expr_2, expr_3], [x, -%pi, %pi], [y, -%pi, %pi], ['grid, 40, 40]);
and a torus:
(%i9) expr_1: cos(y)*(10.0+6*cos(x))$ (%i10) expr_2: sin(y)*(10.0+6*cos(x))$ (%i11) expr_3: -6*sin(x)$ (%i12) plot3d ([expr_1, expr_2, expr_3], [x, 0, 2*%pi], [y, 0, 2*%pi], ['grid, 40, 40]);
Sometimes it is necessary to define a function to plot the expression. All the arguments to plot3d are evaluated before being passed to plot3d, and so trying to make an expression which does just what is needed may be difficult, and it is just easier to make a function.
(%i13) M: matrix([1, 2, 3, 4], [1, 2, 3, 2], [1, 2, 3, 4], [1, 2, 3, 3])$ (%i14) f(x, y) := float (M [?round(x), ?round(y)])$ (%i15) plot3d (f, [x, 1, 4], [y, 1, 4], ['grid, 4, 4])$
Here is a three-dimensional plot using the gnuplot pm3d terminal.
(%i7) plot3d (atan (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4], [grid, 50, 50], [gnuplot_pm3d, true])$
And a three-dimensional plot without a mesh and with contours projected
on the bottom plane. (Note that the gnuplot_preamble
string must
be entered without any line breaks.)
(%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])$
Finally, a plot where the z-axis is represented by color only.
(%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])$
See the available options in plot_options
.
@ref{Category: Plotting}
Returns a function suitable for the transform function in plot3d. Use
with the plot option transform_xy
.
make_transform ([r, th, z], r*cos(th), r*sin(th), z)$
is a transformation to polar coordinates.
@ref{Category: Plotting}
Assigns one of the global variables for plotting.
option is specified as a list of two or more elements,
in which the first element is one of the keywords
on the plot_options
list.
set_plot_option
evaluates its argument and
returns the complete list plot_options
(after modifying one of its elements).
See also plot_options
, plot2d
, and plot3d
.
Examples:
Modify the grid
and x
values.
When a plot_options
keyword has an assigned value,
quote it to prevent evaluation.
(%i1) set_plot_option ([grid, 30, 40]); (%o1) [[x, - 1.755559702014E+305, 1.755559702014E+305], [y, - 1.755559702014E+305, 1.755559702014E+305], [t, - 3, 3], [grid, 30, 40], [transform_xy, false], [run_viewer, true], [plot_format, gnuplot], [gnuplot_term, default], [gnuplot_out_file, false], [nticks, 10], [adapt_depth, 10], [gnuplot_pm3d, false], [gnuplot_preamble, ], [gnuplot_curve_titles, [default]], [gnuplot_curve_styles, [with lines 3, with lines 1, with lines 2, with lines 5, with lines 4, with lines 6, with lines 7]], [gnuplot_default_term_command, ], [gnuplot_dumb_term_command, set term dumb 79 22], [gnuplot_ps_term_command, set size 1.5, 1.5;set term postscript # eps enhanced color solid 24]] (%i2) x: 42; (%o2) 42 (%i3) set_plot_option (['x, -100, 100]); (%o3) [[x, - 100.0, 100.0], [y, - 1.755559702014E+305, 1.755559702014E+305], [t, - 3, 3], [grid, 30, 40], [transform_xy, false], [run_viewer, true], [plot_format, gnuplot], [gnuplot_term, default], [gnuplot_out_file, false], [nticks, 10], [adapt_depth, 10], [gnuplot_pm3d, false], [gnuplot_preamble, ], [gnuplot_curve_titles, [default]], [gnuplot_curve_styles, [with lines 3, with lines 1, with lines 2, with lines 5, with lines 4, with lines 6, with lines 7]], [gnuplot_default_term_command, ], [gnuplot_dumb_term_command, set term dumb 79 22], [gnuplot_ps_term_command, set size 1.5, 1.5;set term postscript # eps enhanced color solid 24]]
@ref{Category: Plotting}
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Opens the pipe to gnuplot used for plotting with the
gnuplot_pipes
format. Is not necessary to manually open the
pipe before plotting.
@ref{Category: Plotting}
Closes the pipe to gnuplot which is used with the gnuplot_pipes
format.
@ref{Category: Plotting}
Closes the pipe to gnuplot which is used with the gnuplot_pipes
format and opens a new pipe.
@ref{Category: Plotting}
Updates the gnuplot window. If gnuplot_replot
is called with a
gnuplot command in a string s, then s
is sent to gnuplot
before reploting the window.
@ref{Category: Plotting}
Resets the state of gnuplot used with the gnuplot_pipes
format. To update the gnuplot window call gnuplot_replot
after
gnuplot_reset
.
@ref{Category: Plotting}
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by root on July, 13 2009 using texi2html 1.76.