1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
3
<!-- Created on September, 20 2006 by texi2html 1.76 -->
5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
6
Karl Berry <karl@freefriends.org>
7
Olaf Bachmann <obachman@mathematik.uni-kl.de>
9
Maintained by: Many creative people <dev@texi2html.cvshome.org>
10
Send bugs and suggestions to <users@texi2html.cvshome.org>
14
<title>Maxima Manual: 8. Plotting</title>
16
<meta name="description" content="Maxima Manual: 8. Plotting">
17
<meta name="keywords" content="Maxima Manual: 8. Plotting">
18
<meta name="resource-type" content="document">
19
<meta name="distribution" content="global">
20
<meta name="Generator" content="texi2html 1.76">
21
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
22
<style type="text/css">
24
a.summary-letter {text-decoration: none}
25
pre.display {font-family: serif}
26
pre.format {font-family: serif}
27
pre.menu-comment {font-family: serif}
28
pre.menu-preformatted {font-family: serif}
29
pre.smalldisplay {font-family: serif; font-size: smaller}
30
pre.smallexample {font-size: smaller}
31
pre.smallformat {font-family: serif; font-size: smaller}
32
pre.smalllisp {font-size: smaller}
33
span.sansserif {font-family:sans-serif; font-weight:normal;}
34
ul.toc {list-style: none}
47
font-family: sans-serif
53
font-family: sans-serif
59
font-family: sans-serif
62
h2,h3,h4,h5,h6 { margin-left: +4%; }
82
background: rgb(200,255,255);
83
font-family: sans-serif
93
background: rgb(255,220,255);
94
/*background: rgb(200,255,255); */
95
/* font-family: fixed */
105
background: rgb(247,242,180); /* kind of sandy */
106
/* background: rgb(200,255,255); */ /* sky blue */
107
font-family: "Lucida Console", monospace
126
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
129
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
131
<a name="Plotting"></a>
133
<table cellpadding="1" cellspacing="1" border="0">
134
<tr><td valign="middle" align="left">[<a href="maxima_7.html#SEC32" title="Previous section in reading order"> < </a>]</td>
135
<td valign="middle" align="left">[<a href="#SEC34" title="Next section in reading order"> > </a>]</td>
136
<td valign="middle" align="left"> </td>
137
<td valign="middle" align="left">[<a href="maxima_7.html#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
138
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
139
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next chapter"> >> </a>]</td>
140
<td valign="middle" align="left"> </td>
141
<td valign="middle" align="left"> </td>
142
<td valign="middle" align="left"> </td>
143
<td valign="middle" align="left"> </td>
144
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
145
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
146
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
147
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
149
<h1 class="chapter"> 8. Plotting </h1>
151
<table class="menu" border="0" cellspacing="0">
152
<tr><td align="left" valign="top"><a href="#SEC34">8.1 Definitions for Plotting</a></td><td> </td><td align="left" valign="top">
157
<a name="Definitions-for-Plotting"></a>
159
<table cellpadding="1" cellspacing="1" border="0">
160
<tr><td valign="middle" align="left">[<a href="#SEC33" title="Previous section in reading order"> < </a>]</td>
161
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next section in reading order"> > </a>]</td>
162
<td valign="middle" align="left"> </td>
163
<td valign="middle" align="left">[<a href="#SEC33" title="Beginning of this chapter or previous chapter"> << </a>]</td>
164
<td valign="middle" align="left">[<a href="#SEC33" title="Up section"> Up </a>]</td>
165
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next chapter"> >> </a>]</td>
166
<td valign="middle" align="left"> </td>
167
<td valign="middle" align="left"> </td>
168
<td valign="middle" align="left"> </td>
169
<td valign="middle" align="left"> </td>
170
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
171
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
172
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
173
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
175
<h2 class="section"> 8.1 Definitions for Plotting </h2>
178
<dt><u>Option variable:</u> <b>in_netmath</b>
179
<a name="IDX235"></a>
181
<dd><p>Default value: <code>false</code>
183
<p>When <code>in_netmath</code> is <code>true</code>,
184
<code>plot3d</code> prints OpenMath output to the console if <code>plot_format</code> is <code>openmath</code>;
185
otherwise <code>in_netmath</code> (even if <code>true</code>) has no effect.
186
<code>in_netmath</code> has no effect on <code>plot2d</code>.
191
<dt><u>Function:</u> <b>openplot_curves</b><i> (<var>list</var>, <var>rest_options</var>)</i>
192
<a name="IDX236"></a>
194
<dd><p>Takes a list of curves such as
195
</p><table><tr><td> </td><td><pre class="example">[[x1, y1, x2, y2, ...], [u1, v1, u2, v2, ...], ..]
196
</pre></td></tr></table><p>or
197
</p><table><tr><td> </td><td><pre class="example">[[[x1, y1], [x2, y2], ...], ...]
198
</pre></td></tr></table><p>and plots them. This is similar to xgraph_curves, but uses the
200
Addtional symbol arguments may be given such as
201
<code>"{xrange -3 4}"</code>
202
The following plots two curves, using big points, labeling the first one
203
<code>jim</code> and the second one <code>jane</code>.
204
</p><table><tr><td> </td><td><pre class="example">(%i1) openplot_curves ([["{plotpoints 1} {pointsize 6}
205
{label jim} {xaxislabel {joe is nice}}"],
206
[1, 2, 3, 4, 5, 6, 7, 8], ["{label jane} {color pink }"],
207
[3, -1, 4, 2, 5, 7]]);
208
</pre></td></tr></table>
209
<p><div class="image"><img src="./figures/plotting1.gif" alt="figures/plotting1"></div>
211
<p>Some other special keywords are <code>xfun</code>, <code>color</code>, <code>plotpoints</code>, <code>linecolors</code>,
212
<code>pointsize</code>, <code>nolines</code>, <code>bargraph</code>, <code>labelposition</code>, <code>xaxislabel</code>, and
213
<code>yaxislabel</code>.
220
<dt><u>Function:</u> <b>plot2d</b><i> (<var>expr</var>, <var>range</var>, ..., <var>options</var>, ...)</i>
221
<a name="IDX237"></a>
223
<dt><u>Function:</u> <b>plot2d</b><i> (<var>parametric_expr</var>)</i>
224
<a name="IDX238"></a>
226
<dt><u>Function:</u> <b>plot2d</b><i> (<var>discrete_expr</var>)</i>
227
<a name="IDX239"></a>
229
<dt><u>Function:</u> <b>plot2d</b><i> ([<var>expr_1</var>, ..., <var>expr_n</var>], <var>x_range</var>, <var>y_range</var>)</i>
230
<a name="IDX240"></a>
232
<dt><u>Function:</u> <b>plot2d</b><i> ([<var>expr_1</var>, ..., <var>expr_n</var>], <var>x_range</var>)</i>
233
<a name="IDX241"></a>
235
<dt><u>Function:</u> <b>plot2d</b><i> (<var>expr</var>, <var>x_range</var>, <var>y_range</var>)</i>
236
<a name="IDX242"></a>
238
<dt><u>Function:</u> <b>plot2d</b><i> (<var>expr</var>, <var>x_range</var>)</i>
239
<a name="IDX243"></a>
241
<dt><u>Function:</u> <b>plot2d</b><i> ([<var>name_1</var>, ..., <var>name_n</var>], <var>x_range</var>, <var>y_range</var>)</i>
242
<a name="IDX244"></a>
244
<dt><u>Function:</u> <b>plot2d</b><i> ([<var>name_1</var>, ..., <var>name_n</var>], <var>x_range</var>)</i>
245
<a name="IDX245"></a>
247
<dt><u>Function:</u> <b>plot2d</b><i> (<var>name</var>, <var>x_range</var>, <var>y_range</var>)</i>
248
<a name="IDX246"></a>
250
<dt><u>Function:</u> <b>plot2d</b><i> (<var>name</var>, <var>x_range</var>)</i>
251
<a name="IDX247"></a>
254
<p>Displays a plot of one or more expressions
255
as a function of one variable.
257
<p>In all cases, <var>expr</var>
258
is an expression to be plotted on the vertical axis as
259
a function of one variable.
260
<var>x_range</var>, the range of the horizontal axis,
261
is a list of the form <code>[<var>variable</var>, <var>min</var>, <var>max</var>]</code>,
262
where <var>variable</var> is a variable which appears in <var>expr</var>.
263
<var>y_range</var>, the range of the vertical axis,
264
is a list of the form <code>[y, <var>min</var>, <var>max</var>]</code>.
266
<p><code>plot2d (<var>expr</var>, <var>x_range</var>)</code>
267
plots <var>expr</var> as a function of the variable named in <var>x_range</var>,
268
over the range specified in <var>x_range</var>.
269
If the vertical range is not otherwise specified by <code>set_plot_option</code>,
270
it is chosen automatically.
271
All options are assumed to have default values unless otherwise specified by <code>set_plot_option</code>.
273
<p><code>plot2d (<var>expr</var>, <var>x_range</var>, <var>y_range</var>)</code>
274
plots <var>expr</var> as a function of the variable named in <var>x_range</var>,
275
over the range specified in <var>x_range</var>.
276
The vertical range is set to <var>y_range</var>.
277
All options are assumed to have default values unless otherwise specified by <code>set_plot_option</code>.
279
<p><code>plot2d ([<var>expr_1</var>, ..., <var>expr_n</var>], <var>x_range</var>)</code>
280
plots <var>expr_1</var>, ..., <var>expr_n</var> as a function of the variable named in <var>x_range</var>,
281
over the range specified in <var>x_range</var>.
282
If the vertical range is not otherwise specified by <code>set_plot_option</code>,
283
it is chosen automatically.
284
All options are assumed to have default values unless otherwise specified by <code>set_plot_option</code>.
286
<p><code>plot2d ([<var>expr_1</var>, ..., <var>expr_n</var>], <var>x_range</var>, <var>y_range</var>)</code>
287
plots <var>expr_1</var>, ..., <var>expr_n</var> as a function of the variable named in <var>x_range</var>,
288
over the range specified in <var>x_range</var>.
289
The vertical range is set to <var>y_range</var>.
290
All options are assumed to have default values unless otherwise specified by <code>set_plot_option</code>.
292
<p>A function to be plotted
293
may be specified as the name of a Maxima or Lisp function or operator,
294
a Maxima lambda expression, or a general Maxima expression.
295
If specified as a name or a lambda expression,
296
the function must be a function of one argument.
300
<p>Plotting an expression, and setting some commonly-used parameters.
302
<table><tr><td> </td><td><pre class="example">(%i1) plot2d (sin(x), [x, -5, 5])$
303
(%i2) plot2d (sec(x), [x, -2, 2], [y, -20, 20], [nticks, 200])$
304
</pre></td></tr></table>
305
<p><div class="image"><img src="./figures/plotting2.gif" alt="figures/plotting2"></div><div class="image"><img src="./figures/plotting3.gif" alt="figures/plotting3"></div>
307
<p><b>Plotting functions by name.</b>
309
<table><tr><td> </td><td><pre class="example">(%i1) F(x) := x^2 $
311
(%i2) :lisp (defun |$g| (x) (m* x x x))
314
(%i2) H(x) := if x < 0 then x^4 - 1 else 1 - x^5 $
316
(%i3) plot2d (F, [u, -1, 1])$
318
(%i4) plot2d ([F, G, H], [u, -1, 1])$
319
</pre></td></tr></table>
320
<p><div class="image"><img src="./figures/plotting4.gif" alt="figures/plotting4"></div><div class="image"><img src="./figures/plotting5.gif" alt="figures/plotting5"></div>
322
<p>Anywhere there may be an ordinary expression, there may be a parametric expression:
323
<var>parametric_expr</var> is a list of the form
324
<code>[parametric, <var>x_expr</var>, <var>y_expr</var>, <var>t_range</var>, <var>options</var>]</code>.
325
Here <var>x_expr</var> and <var>y_expr</var> are expressions of 1 variable <var>var</var> which is
326
the first element of the range <var>trange</var>.
327
The plot is of the path traced out by the pair
328
<code>[<var>x_expr</var>, <var>y_expr</var>]</code> as <var>var</var> varies in <var>trange</var>.
330
<p>In the following example, we plot a circle, then we do
331
the plot with only a few points used, so that we get a star,
332
and finally we plot this together with an ordinary function of X.
334
<p><b>Parametric plot examples:</b>
338
Plot a circle with a parametric plot.
339
<table><tr><td> </td><td><pre class="example">(%i1) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
341
</pre></td></tr></table>
342
<p><div class="image"><img src="./figures/plotting6.gif" alt="figures/plotting6"></div>
345
Plot a star: join eight points on the circumference of a circle.
346
<table><tr><td> </td><td><pre class="example">(%i2) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
348
</pre></td></tr></table>
349
<p><div class="image"><img src="./figures/plotting7.gif" alt="figures/plotting7"></div>
352
Plot a cubic polynomial with an ordinary plot and a circle with a parametric
354
<table><tr><td> </td><td><pre class="example">(%i3) plot2d ([x^3+2, [parametric, cos(t), sin(t), [t, -5, 5],
355
[nticks, 80]]], [x, -3, 3])$
356
</pre></td></tr></table>
357
<p><div class="image"><img src="./figures/plotting8.gif" alt="figures/plotting8"></div>
361
<p>Discrete expressions may also be used instead or ordinary or
362
parametric expressions:
363
<var>discrete_expr</var> is a list of the form
364
<code>[discrete, <var>x_list</var>, <var>y_list</var>]</code>
366
<code>[discrete, <var>xy_list</var>]</code>,
367
where <var>xy_list</var> is a list of <code>[<var>x</var>,<var>y</var>]</code> pairs.
369
<p><b>Discrete plot examples:</b>
374
<table><tr><td> </td><td><pre class="example">(%i1) xx:makelist(x,x,0,10)$
375
(%i2) yy:makelist(exp(-x*1.0),x,0,10)$
376
(%i3) xy:makelist([x,x*x],x,0,5)$
377
</pre></td></tr></table>
379
Plot with line segments.
380
<table><tr><td> </td><td><pre class="example">(%i4) plot2d([discrete,xx,yy])$
381
</pre></td></tr></table>
382
<p><div class="image"><img src="./figures/plotting9.gif" alt="figures/plotting9"></div>
385
Plot with line segments, using a list of pairs.
386
<table><tr><td> </td><td><pre class="example">(%i5) plot2d([discrete,xy])$
387
</pre></td></tr></table>
388
<p><div class="image"><img src="./figures/plotting10.gif" alt="figures/plotting10"></div>
392
<table><tr><td> </td><td><pre class="example">(%i6) plot2d([discrete,xx,yy],[gnuplot_curve_styles,
393
["with points"]])$
394
</pre></td></tr></table>
395
<p><div class="image"><img src="./figures/plotting11.gif" alt="figures/plotting11"></div>
398
Plot the curve <code>cos(<var>x</var>)</code> using lines and (<var>xx</var>,<var>yy</var>)
400
<table><tr><td> </td><td><pre class="example">(%i7) plot2d([cos(x),[discrete,xx,yy]],[x,0,10],
401
[gnuplot_curve_styles,
402
["with lines","with points pointsize 3"]])$
403
</pre></td></tr></table>
404
<p><div class="image"><img src="./figures/plotting12.gif" alt="figures/plotting12"></div>
408
<p>See also <code>plot_options</code>, which describes plotting options and has more examples.
413
<dt><u>Function:</u> <b>xgraph_curves</b><i> (<var>list</var>)</i>
414
<a name="IDX248"></a>
416
<dd><p>graphs the list of `point sets' given in list by using xgraph. If the program
417
xgraph is not installed, this command will fail.
419
<p>A point set may be of the form
421
<table><tr><td> </td><td><pre class="example">[x0, y0, x1, y1, x2, y2, ...]
422
</pre></td></tr></table><p>or
423
</p><table><tr><td> </td><td><pre class="example">[[x0, y0], [x1, y1], ...]
424
</pre></td></tr></table><p>A point set may also contain symbols which give labels or other
427
<table><tr><td> </td><td><pre class="example">xgraph_curves ([pt_set1, pt_set2, pt_set3]);
428
</pre></td></tr></table>
429
<p>graph the three point sets as three curves.
431
<table><tr><td> </td><td><pre class="example">pt_set: append (["NoLines: True", "LargePixels: true"],
432
[x0, y0, x1, y1, ...]);
433
</pre></td></tr></table>
435
<p>would make the point set [and subsequent ones], have
436
no lines between points, and to use large pixels.
437
See the man page on xgraph for more options to specify.
439
<table><tr><td> </td><td><pre class="example">pt_set: append ([concat ("\"", "x^2+y")], [x0, y0, x1, y1, ...]);
440
</pre></td></tr></table>
442
<p>would make there be a "label" of "x^2+y" for this particular
443
point set. The <code>"</code> at the beginning is what tells
444
xgraph this is a label.
446
<table><tr><td> </td><td><pre class="example">pt_set: append ([concat ("TitleText: Sample Data")], [x0, ...])$
447
</pre></td></tr></table>
449
<p>would make the main title of the plot be "Sample Data" instead
450
of "Maxima Plot".
452
<p>To make a bar graph with bars which are 0.2 units wide, and
453
to plot two possibly different such bar graphs:
454
</p><table><tr><td> </td><td><pre class="example">(%i1) xgraph_curves ([append (["BarGraph: true", "NoLines: true",
455
"BarWidth: .2"], create_list ([i - .2, i^2], i, 1, 3)),
456
append (["BarGraph: true", "NoLines: true", "BarWidth: .2"],
457
create_list ([i + .2, .7*i^2], i, 1, 3))]);
458
</pre></td></tr></table>
459
<p><div class="image"><img src="./figures/plotting13.gif" alt="figures/plotting13"></div>
463
<p>A temporary file <tt>`xgraph-out'</tt> is used.
470
<dt><u>System variable:</u> <b>plot_options</b>
471
<a name="IDX249"></a>
473
<dd><p>Elements of this list state the default options for plotting.
474
If an option is present in a <code>plot2d</code> or <code>plot3d</code> call,
475
that value takes precedence over the default option.
476
Otherwise, the value in <code>plot_options</code> is used.
477
Default options are assigned by <code>set_plot_option</code>.
479
<p>Each element of <code>plot_options</code> is a list of two or more items.
480
The first item is the name of an option, and the remainder comprises the value or values
481
assigned to the option.
482
In some cases the, the assigned value is a list, which may comprise several items.
484
<p>The plot options which are recognized by <code>plot2d</code> and <code>plot3d</code> are the following:
488
Option: <code>plot_format</code> determines which plotting package is used by <code>plot2d</code> and <code>plot3d</code>.
492
Default value: <code>gnuplot</code>
493
Gnuplot is the default, and most advanced, plotting package. It
494
requires an external gnuplot installation.
496
Value: <code>mgnuplot</code>
497
Mgnuplot is a Tk-based wrapper around gnuplot. It is included in the
498
Maxima distribution. Mgnuplot offers a rudimentary GUI for gnuplot,
499
but has fewer overall features than the plain gnuplot
500
interface. Mgnuplot requires an external gnuplot installation and
503
Value: <code>openmath</code>
504
Openmath is a Tcl/Tk GUI plotting program. It is included in the
507
Value: <code>ps</code>
508
Generates simple PostScript files directly from
509
Maxima. Much more sophisticated PostScript output can be generated from gnuplot,
510
by leaving the option <code>plot_format</code> unspecified (to accept the default),
511
and setting the option <code>gnuplot_term</code> to <code>ps</code>.
515
Option: <code>run_viewer</code> controls whether or not the appropriate viewer for the plot
516
format should be run.
520
Default value: <code>true</code> Execute the viewer program.
522
Value: <code>false</code> Do not execute the viewer program.
526
<code>gnuplot_term</code> Sets the output terminal type for gnuplot.
529
Default value: <code>default</code>
530
Gnuplot output is displayed in a separate graphical window.
533
Value: <code>dumb</code>
534
Gnuplot output is displayed in the Maxima console by an "ASCII art" approximation to graphics.
537
Value: <code>ps</code>
538
Gnuplot generates commands in the PostScript page description language.
540
<code>gnuplot_out_file</code> is set to <var>filename</var>, gnuplot writes the PostScript commands to <var>filename</var>.
541
Otherwise, it is saved as <code>maxplot.ps</code> file.
544
Value: any other valid gnuplot term specification
545
Gnuplot can generate output in many other graphical formats such
546
as png, jpeg, svg etc. To create plot in all these formats the
547
<code>gnuplot_term</code> can be set to any supported gnuplot term name (symbol)
548
or even full gnuplot term specification with any valid options (string).
549
For example <code>[gnuplot_term,png]</code> creates output in PNG (Portable
550
Network Graphics) format while <code>[gnuplot_term,"png size 1000,1000"]</code>
551
creates PNG of 1000x1000 pixels size.
552
If the option <code>gnuplot_out_file</code> is set to <var>filename</var>, gnuplot
553
writes the output to <var>filename</var>. Otherwise, it is saved as
554
<code>maxplot.<var>term</var></code> file, where <var>term</var> is gnuplot
560
Option: <code>gnuplot_out_file</code> Write gnuplot output to a file.
564
Default value: <code>false</code> No output file specified.
566
Value: <var>filename</var>
567
Example: <code>[gnuplot_out_file, "myplot.ps"]</code>
568
This example sends PostScript output to the file <code>myplot.ps</code> when
569
used in conjunction with the PostScript gnuplot terminal.
573
Option: <code>x</code>
574
The default horizontal range.
575
<table><tr><td> </td><td><pre class="example">[x, - 3, 3]
576
</pre></td></tr></table><p>Sets the horizontal range to [-3, 3].
579
Option: <code>y</code>
580
The default vertical range.
581
<table><tr><td> </td><td><pre class="example">[y, - 3, 3]
582
</pre></td></tr></table><p>Sets the vertical range to [-3, 3].
585
Option: <code>t</code>
586
The default range for the parameter in parametric plots.
587
<table><tr><td> </td><td><pre class="example">[t, 0, 10]
588
</pre></td></tr></table><p>Sets the parametric variable range to [0, 10].
591
Option: <code>nticks</code>
592
Initial number of points
593
used by the adaptive plotting routine.
594
<table><tr><td> </td><td><pre class="example">[nticks, 20]
595
</pre></td></tr></table><p>The default for <code>nticks</code> is 10.
598
Option: <code>adapt_depth</code>
599
The maximum number of splittings used by the adaptive plotting routine.
600
<table><tr><td> </td><td><pre class="example">[adapt_depth, 5]
601
</pre></td></tr></table><p>The default for <code>adapt_depth</code> is 10.
604
Option: <code>grid</code>
605
Sets the number of grid points to use in the x- and y-directions
606
for three-dimensional plotting.
607
<table><tr><td> </td><td><pre class="example">[grid, 50, 50]
608
</pre></td></tr></table><p>sets the grid to 50 by 50 points. The default grid is 30 by 30.
611
Option: <code>transform_xy</code>
612
Allows transformations to be applied to three-dimensional plots.
613
<table><tr><td> </td><td><pre class="example">[transform_xy, false]
614
</pre></td></tr></table><p>The default <code>transform_xy</code> is <code>false</code>. If it is not <code>false</code>, it should be
616
</p><table><tr><td> </td><td><pre class="example">make_transform([x,y,z], f1(x,y,z), f2(x,y,z), f3(x,y,z))$
617
</pre></td></tr></table><p>The <code>polar_xy</code> transformation is built in. It gives the same
619
</p><table><tr><td> </td><td><pre class="example">make_transform ([r, th, z], r*cos(th), r*sin(th), z)$
620
</pre></td></tr></table>
622
Option: <code>colour_z</code> is specific to the <code>ps</code> plot format.
623
<table><tr><td> </td><td><pre class="example">[colour_z, true]
624
</pre></td></tr></table><p>The default value for <code>colour_z</code> is <code>false</code>.
627
Option: <code>view_direction</code>
628
Specific to the <code>ps</code> plot format.
629
<table><tr><td> </td><td><pre class="example">[view_direction, 1, 1, 1]
630
</pre></td></tr></table><p>The default <code>view_direction</code> is [1, 1, 1].
633
<p>There are several plot options specific to gnuplot.
634
All of these options (except <code>gnuplot_pm3d</code>) are raw
635
gnuplot commands, specified as strings. Refer to the gnuplot documentation for more details.
639
Option: <code>gnuplot_pm3d</code> Controls the usage PM3D mode, which has advanced 3D
640
features. PM3D is only available in gnuplot versions after 3.7. The
641
default value for <code>gnuplot_pm3d</code> is <code>false</code>.
645
<table><tr><td> </td><td><pre class="example">[gnuplot_pm3d, true]
646
</pre></td></tr></table>
648
Option: <code>gnuplot_preamble</code> Inserts gnuplot commands before the plot is
649
drawn. Any valid gnuplot commands may be used. Multiple commands
650
should be separated with a semi-colon. The example shown produces a
651
log scale plot. The default value for <code>gnuplot_preamble</code> is the empty string <code>""</code>.
655
<table><tr><td> </td><td><pre class="example">[gnuplot_preamble, "set log y"]
656
</pre></td></tr></table>
658
Option: <code>gnuplot_curve_titles</code> Controls the titles given in the plot key. The
659
default value is <code>[default]</code>, which automatically sets the title of each
660
curve to the function plotted. If not <code>[default]</code>, <code>gnuplot_curve_titles</code>
661
should contain a list of strings,
662
each of which is <code>"title '<var>title_string</var>'"</code>.
663
(To disable the plot key, add <code>"set nokey"</code> to <code>gnuplot_preamble</code>.)
667
<table><tr><td> </td><td><pre class="example">[gnuplot_curve_titles,
668
["title 'My first function'", "title 'My second function'"]]
669
</pre></td></tr></table>
671
Option: <code>gnuplot_curve_styles</code> A list of strings controlling the appearance
672
of curves, i.e., color, width, dashing, etc., to be sent to the
673
gnuplot plot command. The default value is
674
<code>["with lines 3", "with lines 1", "with lines 2", "with lines 5", "with lines 4", "with lines 6", "with lines 7"]</code>, which cycles through different colors. See the
675
gnuplot documentation for <code>plot</code> for more information.
679
<table><tr><td> </td><td><pre class="example">[gnuplot_curve_styles, ["with lines 7", "with lines 2"]]
680
</pre></td></tr></table>
682
Option: <code>gnuplot_default_term_command</code> The gnuplot command to set the
683
terminal type for the default terminal. The default value is the empty string <code>""</code>,
684
i.e., use gnuplot's default.
688
<table><tr><td> </td><td><pre class="example">[gnuplot_default_term_command, "set term x11"]
689
</pre></td></tr></table>
691
Option: <code>gnuplot_dumb_term_command</code> The gnuplot command to set the
692
terminal type for the dumb terminal. The default value is <code>"set term dumb 79 22"</code>,
693
which makes the text output 79 characters by 22
698
<table><tr><td> </td><td><pre class="example">[gnuplot_dumb_term_command, "set term dumb 132 50"]
699
</pre></td></tr></table>
701
Option: <code>gnuplot_ps_term_command</code> The gnuplot command to set the terminal
702
type for the PostScript terminal. The default value is
703
<code>"set size 1.5, 1.5;set term postscript eps enhanced color solid 24"</code>,
705
size to 1.5 times gnuplot's default, and the font size to 24, among
706
other things. See the gnuplot documentation for <code>set term postscript</code> for more information.
710
<table><tr><td> </td><td><pre class="example">[gnuplot_ps_term_command,
711
"set term postscript eps enhanced color solid 18"]
712
</pre></td></tr></table>
719
Saves a plot of <code>sin(x)</code> to the file <code>sin.eps</code>.
721
<table><tr><td> </td><td><pre class="example">(%i1) plot2d (sin(x), [x, 0, 2*%pi], [gnuplot_term, ps],
722
[gnuplot_out_file, "sin.eps"])$
723
</pre></td></tr></table>
726
Uses the y option to chop off singularities and the gnuplot_preamble
727
option to put the key at the bottom of the plot instead of the top.
729
<table><tr><td> </td><td><pre class="example">(%i2) plot2d ([gamma(x), 1/gamma(x)], [x, -4.5, 5], [y, -10, 10],
730
[gnuplot_preamble, "set key bottom"])$
731
</pre></td></tr></table>
732
<p><div class="image"><img src="./figures/plotting14.gif" alt="figures/plotting14"></div>
736
Uses a very complicated <code>gnuplot_preamble</code> to produce fancy x-axis labels.
737
(Note that the <code>gnuplot_preamble</code> string must be entered without any line breaks.)
739
<table><tr><td> </td><td><pre class="example">(%i3) my_preamble: "set xzeroaxis; set xtics ('-2pi' -6.283, \
740
'-3pi/2' -4.712, '-pi' -3.1415, '-pi/2' -1.5708, '0' 0, \
741
'pi/2' 1.5708, 'pi' 3.1415,'3pi/2' 4.712, '2pi' 6.283)"$
743
(%i4) plot2d([cos(x), sin(x), tan(x), cot(x)],
744
[x, -2*%pi, 2.1*%pi], [y, -2, 2],
745
[gnuplot_preamble, my_preamble]);
746
</pre></td></tr></table>
747
<p><div class="image"><img src="./figures/plotting15.gif" alt="figures/plotting15"></div>
751
Uses a very complicated <code>gnuplot_preamble</code> to produce fancy x-axis labels,
752
and produces PostScript
753
output that takes advantage of the advanced text formatting available
755
(Note that the <code>gnuplot_preamble</code> string must be entered without any line breaks.)
757
<table><tr><td> </td><td><pre class="example">(%i5) my_preamble: "set xzeroaxis; set xtics ('-2{/Symbol p}' \
758
-6.283, '-3{/Symbol p}/2' -4.712, '-{/Symbol p}' -3.1415, \
759
'-{/Symbol p}/2' -1.5708, '0' 0,'{/Symbol p}/2' 1.5708, \
760
'{/Symbol p}' 3.1415,'3{/Symbol p}/2' 4.712, '2{/Symbol p}' \
763
(%i6) plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi],
764
[y, -2, 2], [gnuplot_preamble, my_preamble],
765
[gnuplot_term, ps], [gnuplot_out_file, "trig.eps"]);
766
</pre></td></tr></table>
769
A three-dimensional plot using the gnuplot pm3d terminal.
771
<table><tr><td> </td><td><pre class="example">(%i7) plot3d (atan (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4],
772
[grid, 50, 50], [gnuplot_pm3d, true])$
773
</pre></td></tr></table>
774
<p><div class="image"><img src="./figures/plotting16.gif" alt="figures/plotting16"></div>
778
A three-dimensional plot without a mesh and with contours
779
projected on the bottom plane.
781
<table><tr><td> </td><td><pre class="example">(%i8) my_preamble: "set pm3d at s;unset surface;set contour;\
782
set cntrparam levels 20;unset key"$
783
(%i9) plot3d(atan(-x^2 + y^3/4), [x, -4, 4], [y, -4, 4],
784
[grid, 50, 50], [gnuplot_pm3d, true],
785
[gnuplot_preamble, my_preamble])$
786
</pre></td></tr></table>
787
<p><div class="image"><img src="./figures/plotting17.gif" alt="figures/plotting17"></div>
791
A plot where the z-axis is represented by color only.
792
(Note that the <code>gnuplot_preamble</code> string must be entered without any line breaks.)
794
<table><tr><td> </td><td><pre class="example">(%i10) plot3d (cos (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4],
795
[gnuplot_preamble, "set view map; unset surface"],
796
[gnuplot_pm3d, true], [grid, 150, 150])$
797
</pre></td></tr></table>
798
<p><div class="image"><img src="./figures/plotting18.gif" alt="figures/plotting18"></div>
803
<dt><u>Function:</u> <b>plot3d</b><i> (<var>expr</var>, <var>x_range</var>, <var>y_range</var>, ..., <var>options</var>, ...)</i>
804
<a name="IDX250"></a>
806
<dt><u>Function:</u> <b>plot3d</b><i> (<var>name</var>, <var>x_range</var>, <var>y_range</var>, ..., <var>options</var>, ...)</i>
807
<a name="IDX251"></a>
809
<dt><u>Function:</u> <b>plot3d</b><i> ([<var>expr_1</var>, <var>expr_2</var>, <var>expr_3</var>], <var>x_rge</var>, <var>y_rge</var>)</i>
810
<a name="IDX252"></a>
812
<dt><u>Function:</u> <b>plot3d</b><i> ([<var>name_1</var>, <var>name_2</var>, <var>name_3</var>], <var>x_range</var>, <var>y_range</var>, ..., <var>options</var>, ...)</i>
813
<a name="IDX253"></a>
815
<dd><p>Displays a plot of one or three expressions as functions of two variables.
817
<table><tr><td> </td><td><pre class="example">(%i1) plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2]);
818
</pre></td></tr></table>
819
<p><div class="image"><img src="./figures/plotting19.gif" alt="figures/plotting19"></div>
821
<p>plots <code>z = 2^(-u^2+v^2)</code> with <code>u</code> and <code>v</code> varying in [-3,3] and
822
[-2,2] respectively, and with <var>u</var> on the x axis, and <code>v</code> on the y
825
<p>The same graph can be plotted using openmath:
827
<table><tr><td> </td><td><pre class="example">(%i2) plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2],
828
[plot_format, openmath]);
829
</pre></td></tr></table>
830
<p><div class="image"><img src="./figures/plotting25.gif" alt="figures/plotting25"></div>
833
<p>in this case the mouse can be used to rotate the plot to look at the surface
834
from different sides.
836
<p>An example of the third pattern of arguments is
838
<table><tr><td> </td><td><pre class="example">(%i3) plot3d ([cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)),
839
y*sin(x/2)], [x, -%pi, %pi], [y, -1, 1], ['grid, 50, 15]);
840
</pre></td></tr></table>
841
<p><div class="image"><img src="./figures/plotting20.gif" alt="figures/plotting20"></div>
843
<p>which plots a Moebius band, parametrized by the three expressions given
844
as the first argument to <code>plot3d</code>. An additional optional argument
845
<code>['grid, 50, 15]</code> gives the grid number of rectangles in the x direction and
848
<p>The function to be plotted
849
may be specified as the name of a Maxima or Lisp function or operator,
850
a Maxima lambda expression, or a general Maxima expression.
851
In the form <code>plot3d (<var>f</var>, ...)</code> where <var>f</var> is the
852
name of a function or a lambda expression,
853
the function must be a function of two arguments.
854
In the form <code>plot3d ([<var>f_1</var>, <var>f_2</var>, <var>f_3</var>], ...)</code>
855
where <var>f_1</var>, <var>f_2</var>, and <var>f_3</var> are names of functions or lambda expressions,
856
each function must be a function of three arguments.
858
<p>This example shows a plot of the real part of <code>z^1/3</code>.
860
<table><tr><td> </td><td><pre class="example">(%i4) plot3d (r^.33*cos(th/3), [r, 0, 1], [th, 0, 6*%pi],
861
['grid, 12, 80], ['transform_xy, polar_to_xy],
862
['view_direction, 1, 1, 1.4], ['colour_z, true]);
863
</pre></td></tr></table>
864
<p><div class="image"><img src="./figures/plotting21.gif" alt="figures/plotting21"></div>
867
<p>Here the <code>view_direction</code> option indicates the direction from which we
868
take a projection. We actually do this from infinitely far away,
869
but parallel to the line from <code>view_direction</code> to the origin. This
870
is currently only used in <code>ps</code> plot_format, since the other viewers
871
allow interactive rotating of the object.
873
<p>Other examples are the Klein bottle:
875
<table><tr><td> </td><td><pre class="example">(%i5) expr_1: 5*cos(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)
877
(%i6) expr_2: -5*sin(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)
879
(%i7) expr_3: 5*(-sin(x/2)*cos(y) + cos(x/2)*sin(2*y))$
881
(%i8) plot3d ([expr_1, expr_2, expr_3], [x, -%pi, %pi],
882
[y, -%pi, %pi], ['grid, 40, 40]);
883
</pre></td></tr></table>
884
<p><div class="image"><img src="./figures/plotting22.gif" alt="figures/plotting22"></div>
888
<table><tr><td> </td><td><pre class="example">(%i9) expr_1: cos(y)*(10.0+6*cos(x))$
889
(%i10) expr_2: sin(y)*(10.0+6*cos(x))$
890
(%i11) expr_3: -6*sin(x)$
891
(%i12) plot3d ([expr_1, expr_2, expr_3], [x, 0, 2*%pi],
892
[y, 0, 2*%pi], ['grid, 40, 40]);
893
</pre></td></tr></table>
894
<p><div class="image"><img src="./figures/plotting23.gif" alt="figures/plotting23"></div>
896
<p>Sometimes it is necessary to define a function to plot the expression. All
897
the arguments to plot3d are evaluated before being passed to plot3d, and
898
so trying to make an expression which does just what is needed may be
899
difficult, and it is just easier to make a function.
901
<table><tr><td> </td><td><pre class="example">(%i13) M: matrix([1, 2, 3, 4], [1, 2, 3, 2], [1, 2, 3, 4],
903
(%i14) f(x, y) := float (M [?round(x), ?round(y)])$
904
(%i15) plot3d (f, [x, 1, 4], [y, 1, 4], ['grid, 4, 4])$
905
</pre></td></tr></table>
906
<p><div class="image"><img src="./figures/plotting24.gif" alt="figures/plotting24"></div>
908
<p>See <code>plot_options</code> for more examples.
914
<dt><u>Function:</u> <b>make_transform</b><i> (<var>vars</var>, <var>fx</var>, <var>fy</var>, <var>fz</var>)</i>
915
<a name="IDX254"></a>
917
<dd><p>Returns a function suitable for the transform function in plot3d. Use
918
with the plot option <code>transform_xy</code>.
919
</p><table><tr><td> </td><td><pre class="example">make_transform ([r, th, z], r*cos(th), r*sin(th), z)$
920
</pre></td></tr></table><p>is a transformation to polar coordinates.
924
<dt><u>Function:</u> <b>plot2d_ps</b><i> (<var>expr</var>, <var>range</var>)</i>
925
<a name="IDX255"></a>
927
<dd><p>Writes to pstream a sequence of PostScript commands which
928
plot <var>expr</var> over <var>range</var>.
930
<p><var>expr</var> is an expression.
931
<var>range</var> is a list of the form <code>[<var>x</var>, <var>min</var>, <var>max</var>]</code>
932
in which <var>x</var> is a variable which appears in <var>expr</var>.
934
<p>See also <code>closeps</code>.
940
<dt><u>Function:</u> <b>closeps</b><i> ()</i>
941
<a name="IDX256"></a>
943
<dd><p>This should usually becalled at the end of a sequence of plotting
944
commands. It closes the current output stream <var>pstream</var>, and sets
945
it to nil. It also may be called at the start of a plot, to ensure
946
pstream is closed if it was open. All commands which write to
947
pstream, open it if necessary. <code>closeps</code> is separate from the other
948
plotting commands, since we may want to plot 2 ranges or superimpose
949
several plots, and so must keep the stream open.
953
<dt><u>Function:</u> <b>set_plot_option</b><i> (<var>option</var>)</i>
954
<a name="IDX257"></a>
956
<dd><p>Assigns one of the global variables for plotting.
957
<var>option</var> is specified as a list of two or more elements,
958
in which the first element is one of the keywords
959
on the <code>plot_options</code> list.
961
<p><code>set_plot_option</code> evaluates its argument.
962
<code>set_plot_option</code> returns <code>plot_options</code>
963
(after modifying one of its elements).
965
<p>See also <code>plot_options</code>, <code>plot2d</code>, and <code>plot3d</code>.
969
<p>Modify the <code>grid</code> and <code>x</code> values.
970
When a <code>plot_options</code> keyword has an assigned value,
971
quote it to prevent evaluation.
974
<table><tr><td> </td><td><pre class="example">(%i1) set_plot_option ([grid, 30, 40]);
975
(%o1) [[x, - 1.755559702014E+305, 1.755559702014E+305],
976
[y, - 1.755559702014E+305, 1.755559702014E+305], [t, - 3, 3],
977
[grid, 30, 40], [view_direction, 1, 1, 1], [colour_z, false],
978
[transform_xy, false], [run_viewer, true],
979
[plot_format, gnuplot], [gnuplot_term, default],
980
[gnuplot_out_file, false], [nticks, 10], [adapt_depth, 10],
981
[gnuplot_pm3d, false], [gnuplot_preamble, ],
982
[gnuplot_curve_titles, [default]],
983
[gnuplot_curve_styles, [with lines 3, with lines 1,
984
with lines 2, with lines 5, with lines 4, with lines 6,
985
with lines 7]], [gnuplot_default_term_command, ],
986
[gnuplot_dumb_term_command, set term dumb 79 22],
987
[gnuplot_ps_term_command, set size 1.5, 1.5;set term postscript #
988
eps enhanced color solid 24]]
991
(%i3) set_plot_option (['x, -100, 100]);
992
(%o3) [[x, - 100.0, 100.0], [y, - 1.755559702014E+305,
993
1.755559702014E+305], [t, - 3, 3], [grid, 30, 40],
994
[view_direction, 1, 1, 1], [colour_z, false],
995
[transform_xy, false], [run_viewer, true],
996
[plot_format, gnuplot], [gnuplot_term, default],
997
[gnuplot_out_file, false], [nticks, 10], [adapt_depth, 10],
998
[gnuplot_pm3d, false], [gnuplot_preamble, ],
999
[gnuplot_curve_titles, [default]],
1000
[gnuplot_curve_styles, [with lines 3, with lines 1,
1001
with lines 2, with lines 5, with lines 4, with lines 6,
1002
with lines 7]], [gnuplot_default_term_command, ],
1003
[gnuplot_dumb_term_command, set term dumb 79 22],
1004
[gnuplot_ps_term_command, set size 1.5, 1.5;set term postscript #
1005
eps enhanced color solid 24]]
1006
</pre></td></tr></table>
1010
<dt><u>Function:</u> <b>psdraw_curve</b><i> (<var>ptlist</var>)</i>
1011
<a name="IDX258"></a>
1013
<dd><p>Draws a curve connecting the points in <var>ptlist</var>. The latter
1014
may be of the form <code>[x0, y0, x1, y1, ...]</code> or <code>[[x0, y0], [x1, y1], ...]</code>
1016
<p>The function <code>join</code> is handy for taking a list of x's and a
1017
list of y's and splicing them together.
1019
<p><var>psdraw_curve</var> simply invokes the more primitive function
1020
<var>pscurve</var>. Here is the definition:
1022
<table><tr><td> </td><td><pre class="example">(defun $psdraw_curve (lis)
1023
(p "newpath")
1025
(p "stroke"))
1027
</pre></td></tr></table>
1033
<dt><u>Function:</u> <b>pscom</b><i> (<var>cmd</var>)</i>
1034
<a name="IDX259"></a>
1036
<dd><p><var>cmd</var> is inserted in the PostScript file.
1038
</p><table><tr><td> </td><td><pre class="example">pscom ("4.5 72 mul 5.5 72 mul translate 14 14 scale");
1039
</pre></td></tr></table>
1046
<table cellpadding="1" cellspacing="1" border="0">
1047
<tr><td valign="middle" align="left">[<a href="#SEC33" title="Beginning of this chapter or previous chapter"> << </a>]</td>
1048
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next chapter"> >> </a>]</td>
1049
<td valign="middle" align="left"> </td>
1050
<td valign="middle" align="left"> </td>
1051
<td valign="middle" align="left"> </td>
1052
<td valign="middle" align="left"> </td>
1053
<td valign="middle" align="left"> </td>
1054
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
1055
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
1056
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
1057
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
1061
This document was generated by <em>Robert Dodier</em> on <em>September, 20 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.