Basic usage
The Maxima-Gnuplot interface offers three terminal choices:
default,
ps and
dumb.
Maxima 5.9.0.1cvs http://maxima.sourceforge.net
Using Lisp CMU Common Lisp 18e fedora release 0.fdr.2.e.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(C1) plot2d(sin(x),[x,0,2*%pi]);
(D1)
(C2) plot2d(sin(x),[x,0,2*%pi],[gnuplot_term,ps],[gnuplot_out_file,"sin.eps"]);
output file "sin.eps".
(D2)
Click on the above image to see the actual postscript file
(C3) plot2d(sin(x),[x,0,2*%pi],[gnuplot_term,dumb]);
1 ++--------+--$$$$$$$+---------+---------+---------+---------+--------++
+ $$$ $$$ + + + SIN(x) $$$$$$ +
| $$$ $$ |
| $$ $$$ |
0.5 ++ $$ $$ ++
| $$ $$ |
| $$ $$ |
| $$ $$ |
|$$ $$ |
0 $+ $$ $$ ++
| $$ $$ |
| $$ $$ |
| $$ $$ |
-0.5 ++ $$ $$ ++
| $$ $ |
| $$ $$ |
| $$ $$$ |
+ + + + +$$$$ +$$$ + +
-1 ++--------+---------+---------+---------+---$$$$$$$---------+--------++
0 1 2 3 4 5 6 7
(D3)
Those of us who remember when "vt100" was not just a menu item in a terminal
editor, but an actual
thing that would hurt to drop on your foot, should find the following picture
nostalgic.
More advanced usage
The new adaptive plotting routines (based on an algorithm from
yacas) allow
plotting of functions with singularities.
(C4) plot2d([gamma(x),1/gamma(x)],[x,-4.5,5],[y,-10,10],
[gnuplot_preamble,"set key bottom"]);
(D4)
It is now possible to take advantage of the advanced features of
Gnuplot. Note the tick labels on the horizontal axis in the following figure.
(C5) plot2d([cos(x),sin(x),tan(x),cot(x)],[x,-2*%pi,2*%pi],[y,-2,2],
[gnuplot_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)"]);
(D5)
The postscript version of the previous figure can take advantage of
Gnuplot's enhanced postscript terminal.
(C6)
plot2d([cos(x),sin(x),tan(x)],[x,-2*%pi,2*%pi],[y,-2,2],[gnuplot_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)"],[gnuplot_term,ps],[gnuplot_out_file,"trig.eps"]);
output file "trig.eps"
(D6)
Click on the above image to see the actual postscript file
3D plotting and pm3d
Plotting without pm3d
The default three-dimensional plotting generates a mesh. It works with all
versions of Gnuplot.
(C7) plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50]);
(D7)
Plotting with pm3d
Gnuplot 4.0 includes pm3d, which provides many advanced options for three- and
four-dimensional plotting. Use of pm3d is turned off by default because Gnuplot
4.0 is not yet commonly installed. (Indeed, as of this writing, April 15, 2004,
Gnuplot 4.0 has not yet been officially released.) If Gnuplot 4.0 (or one of the
many earlier cvs/beta releases) is installed, Maxima can take
advantage of the features in pm3d.
The default plot with pm3d includes a mesh and a colored surface.
(C8)
plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]);
(D8)
Several variations are possible. Here is one with no mesh and contours on at
the base.
(C9)
plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true],[gnup
lot_preamble,"set pm3d at s;unset surface;set contour;set cntrparam levels
20;unset key"]);
(D9)
The following variation includes the mesh and puts the colors on the base.
(C10) surface-pm3d-2:
plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true],[gnup
lot_preamble,"set pm3d at b"]);
(D10)
Some functions are too complicated to be practically visualized with a mesh.
(C11) plot3d(cos(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,150,150]);
(D11)
However, the above function can be effectively visualized using pm3d's "map
view."
(C12) 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]);
(D12)