~ubuntu-branches/debian/squeeze/maxima/squeeze

« back to all changes in this revision

Viewing changes to doc/info/maxima_8.html

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-10-18 14:52:42 UTC
  • mto: (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061018145242-vzyrm5hmxr8kiosf
ImportĀ upstreamĀ versionĀ 5.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
 
2
<html>
 
3
<!-- Created on September, 20 2006 by texi2html 1.76 -->
 
4
<!--
 
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>
 
8
            and many others.
 
9
Maintained by: Many creative people <dev@texi2html.cvshome.org>
 
10
Send bugs and suggestions to <users@texi2html.cvshome.org>
 
11
 
 
12
-->
 
13
<head>
 
14
<title>Maxima Manual: 8. Plotting</title>
 
15
 
 
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">
 
23
<!--
 
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}
 
35
body
 
36
{
 
37
    color: black;
 
38
    background: white; 
 
39
    margin-left: 8%;
 
40
    margin-right: 13%;
 
41
}
 
42
 
 
43
h1
 
44
{
 
45
    margin-left: +8%;
 
46
    font-size: 150%;
 
47
    font-family: sans-serif
 
48
}
 
49
 
 
50
h2
 
51
{
 
52
    font-size: 125%;
 
53
    font-family: sans-serif
 
54
}
 
55
 
 
56
h3
 
57
{
 
58
    font-size: 100%;
 
59
    font-family: sans-serif
 
60
}
 
61
 
 
62
h2,h3,h4,h5,h6 { margin-left: +4%; }
 
63
 
 
64
div.textbox
 
65
{
 
66
    border: solid;
 
67
    border-width: thin;
 
68
    /* width: 100%; */
 
69
    padding-top: 1em;
 
70
    padding-bottom: 1em;
 
71
    padding-left: 2em;
 
72
    padding-right: 2em
 
73
}
 
74
 
 
75
div.titlebox
 
76
{
 
77
    border: none;
 
78
    padding-top: 1em;
 
79
    padding-bottom: 1em;
 
80
    padding-left: 2em;
 
81
    padding-right: 2em;
 
82
    background: rgb(200,255,255);
 
83
    font-family: sans-serif
 
84
}
 
85
 
 
86
div.synopsisbox
 
87
{
 
88
    border: none;
 
89
    padding-top: 1em;
 
90
    padding-bottom: 1em;
 
91
    padding-left: 2em;
 
92
    padding-right: 2em;
 
93
     background: rgb(255,220,255);
 
94
    /*background: rgb(200,255,255); */
 
95
    /* font-family: fixed */
 
96
}
 
97
 
 
98
pre.example
 
99
{
 
100
    border: none;
 
101
    padding-top: 1em;
 
102
    padding-bottom: 1em;
 
103
    padding-left: 1em;
 
104
    padding-right: 1em;
 
105
    background: rgb(247,242,180); /* kind of sandy */
 
106
    /* background: rgb(200,255,255); */ /* sky blue */
 
107
    font-family: "Lucida Console", monospace
 
108
}
 
109
 
 
110
div.spacerbox
 
111
{
 
112
    border: none;
 
113
    padding-top: 2em;
 
114
    padding-bottom: 2em
 
115
}
 
116
 
 
117
div.image
 
118
{
 
119
    margin: 0;
 
120
    padding: 1em;
 
121
    text-align: center;
 
122
}
 
123
-->
 
124
</style>
 
125
 
 
126
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
 
127
</head>
 
128
 
 
129
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
 
130
 
 
131
<a name="Plotting"></a>
 
132
<a name="SEC33"></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"> &lt; </a>]</td>
 
135
<td valign="middle" align="left">[<a href="#SEC34" title="Next section in reading order"> &gt; </a>]</td>
 
136
<td valign="middle" align="left"> &nbsp; </td>
 
137
<td valign="middle" align="left">[<a href="maxima_7.html#SEC31" title="Beginning of this chapter or previous chapter"> &lt;&lt; </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"> &gt;&gt; </a>]</td>
 
140
<td valign="middle" align="left"> &nbsp; </td>
 
141
<td valign="middle" align="left"> &nbsp; </td>
 
142
<td valign="middle" align="left"> &nbsp; </td>
 
143
<td valign="middle" align="left"> &nbsp; </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>
 
148
</tr></table>
 
149
<h1 class="chapter"> 8. Plotting </h1>
 
150
 
 
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>&nbsp;&nbsp;</td><td align="left" valign="top">    
 
153
</td></tr>
 
154
</table>
 
155
 
 
156
<hr size="6">
 
157
<a name="Definitions-for-Plotting"></a>
 
158
<a name="SEC34"></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"> &lt; </a>]</td>
 
161
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next section in reading order"> &gt; </a>]</td>
 
162
<td valign="middle" align="left"> &nbsp; </td>
 
163
<td valign="middle" align="left">[<a href="#SEC33" title="Beginning of this chapter or previous chapter"> &lt;&lt; </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"> &gt;&gt; </a>]</td>
 
166
<td valign="middle" align="left"> &nbsp; </td>
 
167
<td valign="middle" align="left"> &nbsp; </td>
 
168
<td valign="middle" align="left"> &nbsp; </td>
 
169
<td valign="middle" align="left"> &nbsp; </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>
 
174
</tr></table>
 
175
<h2 class="section"> 8.1 Definitions for Plotting </h2>
 
176
 
 
177
<dl>
 
178
<dt><u>Option variable:</u> <b>in_netmath</b>
 
179
<a name="IDX235"></a>
 
180
</dt>
 
181
<dd><p>Default value: <code>false</code>
 
182
</p>
 
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>.
 
187
</p>
 
188
</dd></dl>
 
189
 
 
190
<dl>
 
191
<dt><u>Function:</u> <b>openplot_curves</b><i> (<var>list</var>, <var>rest_options</var>)</i>
 
192
<a name="IDX236"></a>
 
193
</dt>
 
194
<dd><p>Takes a list of curves such as
 
195
</p><table><tr><td>&nbsp;</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>&nbsp;</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
 
199
open plot routines.
 
200
Addtional symbol arguments may be given such as
 
201
<code>&quot;{xrange -3 4}&quot;</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>&nbsp;</td><td><pre class="example">(%i1) openplot_curves ([[&quot;{plotpoints 1} {pointsize 6}
 
205
      {label jim} {xaxislabel {joe is nice}}&quot;],
 
206
      [1, 2, 3, 4, 5, 6, 7, 8], [&quot;{label jane} {color pink }&quot;],
 
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>
 
210
</p>
 
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>.
 
214
</p>
 
215
</dd></dl>
 
216
 
 
217
 
 
218
 
 
219
<dl>
 
220
<dt><u>Function:</u> <b>plot2d</b><i> (<var>expr</var>, <var>range</var>, ..., <var>options</var>, ...)</i>
 
221
<a name="IDX237"></a>
 
222
</dt>
 
223
<dt><u>Function:</u> <b>plot2d</b><i> (<var>parametric_expr</var>)</i>
 
224
<a name="IDX238"></a>
 
225
</dt>
 
226
<dt><u>Function:</u> <b>plot2d</b><i> (<var>discrete_expr</var>)</i>
 
227
<a name="IDX239"></a>
 
228
</dt>
 
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>
 
231
</dt>
 
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>
 
234
</dt>
 
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>
 
237
</dt>
 
238
<dt><u>Function:</u> <b>plot2d</b><i> (<var>expr</var>, <var>x_range</var>)</i>
 
239
<a name="IDX243"></a>
 
240
</dt>
 
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>
 
243
</dt>
 
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>
 
246
</dt>
 
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>
 
249
</dt>
 
250
<dt><u>Function:</u> <b>plot2d</b><i> (<var>name</var>, <var>x_range</var>)</i>
 
251
<a name="IDX247"></a>
 
252
</dt>
 
253
<dd>
 
254
<p>Displays a plot of one or more expressions
 
255
as a function of one variable.
 
256
</p>
 
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>.
 
265
</p>
 
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>.
 
272
</p>
 
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>.
 
278
</p>
 
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>.
 
285
</p>
 
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>.
 
291
</p>
 
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.
 
297
</p>
 
298
<p><b>Examples:</b>
 
299
</p>
 
300
<p>Plotting an expression, and setting some commonly-used parameters.
 
301
</p>
 
302
<table><tr><td>&nbsp;</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>
 
306
</p>
 
307
<p><b>Plotting functions by name.</b>
 
308
</p>
 
309
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) F(x) := x^2 $
 
310
 
 
311
(%i2) :lisp (defun |$g| (x) (m* x x x))
 
312
 
 
313
$g
 
314
(%i2) H(x) := if x &lt; 0 then x^4 - 1 else 1 - x^5 $
 
315
 
 
316
(%i3) plot2d (F, [u, -1, 1])$
 
317
 
 
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>
 
321
</p>
 
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>.
 
329
</p>
 
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.
 
333
</p>
 
334
<p><b>Parametric plot examples:</b>
 
335
</p>
 
336
<ul>
 
337
<li>
 
338
Plot a circle with a parametric plot.
 
339
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
 
340
        [nticks, 80]])$
 
341
</pre></td></tr></table>
 
342
<p><div class="image"><img src="./figures/plotting6.gif" alt="figures/plotting6"></div>
 
343
</p>
 
344
</li><li> 
 
345
Plot a star: join eight points on the circumference of a circle.
 
346
<table><tr><td>&nbsp;</td><td><pre class="example">(%i2) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
 
347
        [nticks, 8]])$
 
348
</pre></td></tr></table>
 
349
<p><div class="image"><img src="./figures/plotting7.gif" alt="figures/plotting7"></div>
 
350
</p>
 
351
</li><li>
 
352
Plot a cubic polynomial with an ordinary plot and a circle with a parametric
 
353
plot.
 
354
<table><tr><td>&nbsp;</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>
 
358
</p>
 
359
</li></ul>
 
360
 
 
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>
 
365
or
 
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.
 
368
</p>
 
369
<p><b>Discrete plot examples:</b>
 
370
</p>
 
371
<ul>
 
372
<li>
 
373
Create some lists.
 
374
<table><tr><td>&nbsp;</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>
 
378
</li><li>
 
379
Plot with line segments.
 
380
<table><tr><td>&nbsp;</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>
 
383
</p>
 
384
</li><li>
 
385
Plot with line segments, using a list of pairs.
 
386
<table><tr><td>&nbsp;</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>
 
389
</p>
 
390
</li><li>
 
391
Plot with points.
 
392
<table><tr><td>&nbsp;</td><td><pre class="example">(%i6) plot2d([discrete,xx,yy],[gnuplot_curve_styles,
 
393
      [&quot;with points&quot;]])$
 
394
</pre></td></tr></table>
 
395
<p><div class="image"><img src="./figures/plotting11.gif" alt="figures/plotting11"></div>
 
396
</p>
 
397
</li><li>
 
398
Plot the curve <code>cos(<var>x</var>)</code> using lines and (<var>xx</var>,<var>yy</var>)
 
399
using points.
 
400
<table><tr><td>&nbsp;</td><td><pre class="example">(%i7) plot2d([cos(x),[discrete,xx,yy]],[x,0,10],
 
401
     [gnuplot_curve_styles,
 
402
     [&quot;with lines&quot;,&quot;with points pointsize 3&quot;]])$
 
403
</pre></td></tr></table>
 
404
<p><div class="image"><img src="./figures/plotting12.gif" alt="figures/plotting12"></div>
 
405
</p>
 
406
</li></ul>
 
407
 
 
408
<p>See also <code>plot_options</code>, which describes plotting options and has more examples.
 
409
</p>
 
410
</dd></dl>
 
411
 
 
412
<dl>
 
413
<dt><u>Function:</u> <b>xgraph_curves</b><i> (<var>list</var>)</i>
 
414
<a name="IDX248"></a>
 
415
</dt>
 
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.
 
418
</p>
 
419
<p>A point set may be of the form
 
420
</p>
 
421
<table><tr><td>&nbsp;</td><td><pre class="example">[x0, y0, x1, y1, x2, y2, ...]
 
422
</pre></td></tr></table><p>or
 
423
</p><table><tr><td>&nbsp;</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
 
425
information.
 
426
</p>
 
427
<table><tr><td>&nbsp;</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.
 
430
</p>
 
431
<table><tr><td>&nbsp;</td><td><pre class="example">pt_set: append ([&quot;NoLines: True&quot;, &quot;LargePixels: true&quot;],
 
432
                          [x0, y0, x1, y1, ...]);
 
433
</pre></td></tr></table>
 
434
 
 
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.
 
438
</p>
 
439
<table><tr><td>&nbsp;</td><td><pre class="example">pt_set: append ([concat (&quot;\&quot;&quot;, &quot;x^2+y&quot;)], [x0, y0, x1, y1, ...]);
 
440
</pre></td></tr></table>
 
441
 
 
442
<p>would make there be a &quot;label&quot; of &quot;x^2+y&quot; for this particular
 
443
point set.    The <code>&quot;</code> at the beginning is what tells
 
444
xgraph this is a label.
 
445
</p>
 
446
<table><tr><td>&nbsp;</td><td><pre class="example">pt_set: append ([concat (&quot;TitleText: Sample Data&quot;)], [x0, ...])$
 
447
</pre></td></tr></table>
 
448
 
 
449
<p>would make the main title of the plot be &quot;Sample Data&quot; instead
 
450
of &quot;Maxima Plot&quot;.
 
451
</p>
 
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>&nbsp;</td><td><pre class="example">(%i1) xgraph_curves ([append ([&quot;BarGraph: true&quot;, &quot;NoLines: true&quot;,
 
455
      &quot;BarWidth: .2&quot;], create_list ([i - .2, i^2], i, 1, 3)),
 
456
      append ([&quot;BarGraph: true&quot;, &quot;NoLines: true&quot;, &quot;BarWidth: .2&quot;],
 
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>
 
460
</p>
 
461
 
 
462
 
 
463
<p>A temporary file <tt>`xgraph-out'</tt> is used.
 
464
</p>
 
465
</dd></dl>
 
466
 
 
467
 
 
468
 
 
469
<dl>
 
470
<dt><u>System variable:</u> <b>plot_options</b>
 
471
<a name="IDX249"></a>
 
472
</dt>
 
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>.
 
478
</p>
 
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.
 
483
</p>
 
484
<p>The plot options which are recognized by <code>plot2d</code> and <code>plot3d</code> are the following:
 
485
</p>
 
486
<ul>
 
487
<li>
 
488
Option: <code>plot_format</code> determines which plotting package is used by <code>plot2d</code> and <code>plot3d</code>.
 
489
 
 
490
<ul>
 
491
<li>
 
492
Default value: <code>gnuplot</code>
 
493
Gnuplot is the default, and most advanced, plotting package. It
 
494
requires an external gnuplot installation.
 
495
</li><li>
 
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
 
501
Tcl/Tk.
 
502
</li><li>
 
503
Value: <code>openmath</code>
 
504
Openmath is a Tcl/Tk GUI plotting program. It is included in the
 
505
Maxima distribution.
 
506
</li><li>
 
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>.
 
512
</li></ul>
 
513
 
 
514
</li><li>
 
515
Option: <code>run_viewer</code> controls whether or not the appropriate viewer for the plot
 
516
format should be run.
 
517
 
 
518
<ul>
 
519
<li>
 
520
Default value: <code>true</code> Execute the viewer program.
 
521
</li><li>
 
522
Value: <code>false</code> Do not execute the viewer program.
 
523
</li></ul>
 
524
 
 
525
</li><li>
 
526
<code>gnuplot_term</code> Sets the output terminal type for gnuplot.
 
527
<ul>
 
528
<li>
 
529
Default value: <code>default</code>
 
530
Gnuplot output is displayed in a separate graphical window.
 
531
 
 
532
</li><li>
 
533
Value: <code>dumb</code>
 
534
Gnuplot output is displayed in the Maxima console by an &quot;ASCII art&quot; approximation to graphics.
 
535
 
 
536
</li><li>
 
537
Value: <code>ps</code>
 
538
Gnuplot generates commands in the PostScript page description language.
 
539
If the option
 
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.
 
542
 
 
543
</li><li>
 
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,&quot;png size 1000,1000&quot;]</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 
 
555
terminal name.
 
556
 
 
557
</li></ul>
 
558
 
 
559
</li><li>
 
560
Option: <code>gnuplot_out_file</code> Write gnuplot output to a file.
 
561
 
 
562
<ul>
 
563
<li>
 
564
Default value: <code>false</code> No output file specified.
 
565
</li><li>
 
566
Value: <var>filename</var>
 
567
Example: <code>[gnuplot_out_file, &quot;myplot.ps&quot;]</code>
 
568
This example sends PostScript output to the file <code>myplot.ps</code> when
 
569
used in conjunction with the PostScript gnuplot terminal.
 
570
</li></ul>
 
571
 
 
572
</li><li>
 
573
Option: <code>x</code>
 
574
The default horizontal range.
 
575
<table><tr><td>&nbsp;</td><td><pre class="example">[x, - 3, 3]
 
576
</pre></td></tr></table><p>Sets the horizontal range to [-3, 3].
 
577
</p>
 
578
</li><li>
 
579
Option: <code>y</code>
 
580
The default vertical range.
 
581
<table><tr><td>&nbsp;</td><td><pre class="example">[y, - 3, 3]
 
582
</pre></td></tr></table><p>Sets the vertical range to [-3, 3].
 
583
</p>
 
584
</li><li>
 
585
Option: <code>t</code>
 
586
The default range for the parameter in parametric plots.
 
587
<table><tr><td>&nbsp;</td><td><pre class="example">[t, 0, 10]
 
588
</pre></td></tr></table><p>Sets the parametric variable range to [0, 10].
 
589
</p>
 
590
</li><li>
 
591
Option: <code>nticks</code>
 
592
Initial number of points 
 
593
used by the adaptive plotting routine.
 
594
<table><tr><td>&nbsp;</td><td><pre class="example">[nticks, 20]
 
595
</pre></td></tr></table><p>The default for <code>nticks</code> is 10.
 
596
</p>
 
597
</li><li>
 
598
Option: <code>adapt_depth</code>
 
599
The maximum number of splittings used by the adaptive plotting routine.
 
600
<table><tr><td>&nbsp;</td><td><pre class="example">[adapt_depth, 5]
 
601
</pre></td></tr></table><p>The default for <code>adapt_depth</code> is 10.
 
602
</p>
 
603
</li><li>
 
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>&nbsp;</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.
 
609
</p>
 
610
</li><li>
 
611
Option: <code>transform_xy</code>
 
612
Allows transformations to be applied to three-dimensional plots.
 
613
<table><tr><td>&nbsp;</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
 
615
the output of
 
616
</p><table><tr><td>&nbsp;</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
 
618
transformation as
 
619
</p><table><tr><td>&nbsp;</td><td><pre class="example">make_transform ([r, th, z], r*cos(th), r*sin(th), z)$
 
620
</pre></td></tr></table>
 
621
</li><li>
 
622
Option: <code>colour_z</code> is specific to the <code>ps</code> plot format.
 
623
<table><tr><td>&nbsp;</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>.
 
625
</p>
 
626
</li><li>
 
627
Option: <code>view_direction</code>
 
628
Specific to the <code>ps</code> plot format.
 
629
<table><tr><td>&nbsp;</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].
 
631
</p></li></ul>
 
632
 
 
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.
 
636
</p>
 
637
<ul>
 
638
<li>
 
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>.
 
642
 
 
643
<p>Example:
 
644
</p>
 
645
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_pm3d, true]
 
646
</pre></td></tr></table>
 
647
</li><li>
 
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>&quot;&quot;</code>.
 
652
 
 
653
<p>Example:
 
654
</p>
 
655
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_preamble, &quot;set log y&quot;]
 
656
</pre></td></tr></table>
 
657
</li><li>
 
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>&quot;title '<var>title_string</var>'&quot;</code>.
 
663
(To disable the plot key, add <code>&quot;set nokey&quot;</code> to <code>gnuplot_preamble</code>.)
 
664
 
 
665
<p>Example:
 
666
</p>
 
667
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_curve_titles,
 
668
[&quot;title 'My first function'&quot;, &quot;title 'My second function'&quot;]]
 
669
</pre></td></tr></table>
 
670
</li><li>
 
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>[&quot;with lines 3&quot;, &quot;with lines 1&quot;, &quot;with lines 2&quot;, &quot;with lines 5&quot;, &quot;with lines 4&quot;, &quot;with lines 6&quot;, &quot;with lines 7&quot;]</code>, which cycles through different colors. See the
 
675
gnuplot documentation for <code>plot</code> for more information.
 
676
 
 
677
<p>Example:
 
678
</p>
 
679
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_curve_styles, [&quot;with lines 7&quot;, &quot;with lines 2&quot;]]
 
680
</pre></td></tr></table>
 
681
</li><li>
 
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>&quot;&quot;</code>,
 
684
i.e., use gnuplot's default.
 
685
 
 
686
<p>Example:
 
687
</p>
 
688
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_default_term_command, &quot;set term x11&quot;]
 
689
</pre></td></tr></table>
 
690
</li><li>
 
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>&quot;set term dumb 79 22&quot;</code>,
 
693
which makes the text output 79 characters by 22
 
694
characters.
 
695
 
 
696
<p>Example:
 
697
</p>
 
698
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_dumb_term_command, &quot;set term dumb 132 50&quot;]
 
699
</pre></td></tr></table>
 
700
</li><li>
 
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>&quot;set size 1.5, 1.5;set term postscript eps enhanced color solid 24&quot;</code>,
 
704
which sets the
 
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.
 
707
 
 
708
<p>Example:
 
709
</p>
 
710
<table><tr><td>&nbsp;</td><td><pre class="example">[gnuplot_ps_term_command,
 
711
&quot;set term postscript eps enhanced color solid 18&quot;]
 
712
</pre></td></tr></table>
 
713
</li></ul>
 
714
 
 
715
<p><b>Examples:</b>
 
716
</p>
 
717
<ul>
 
718
<li>
 
719
Saves a plot of <code>sin(x)</code> to the file <code>sin.eps</code>.
 
720
</li></ul>
 
721
<table><tr><td>&nbsp;</td><td><pre class="example">(%i1) plot2d (sin(x), [x, 0, 2*%pi], [gnuplot_term, ps],
 
722
                        [gnuplot_out_file, &quot;sin.eps&quot;])$
 
723
</pre></td></tr></table>
 
724
<ul>
 
725
<li>
 
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.
 
728
</li></ul>
 
729
<table><tr><td>&nbsp;</td><td><pre class="example">(%i2) plot2d ([gamma(x), 1/gamma(x)], [x, -4.5, 5], [y, -10, 10],
 
730
                     [gnuplot_preamble, &quot;set key bottom&quot;])$
 
731
</pre></td></tr></table>
 
732
<p><div class="image"><img src="./figures/plotting14.gif" alt="figures/plotting14"></div>
 
733
</p>
 
734
<ul>
 
735
<li>
 
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.)
 
738
</li></ul>
 
739
<table><tr><td>&nbsp;</td><td><pre class="example">(%i3) my_preamble: &quot;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)&quot;$
 
742
 
 
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>
 
748
</p>
 
749
<ul>
 
750
<li>
 
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
 
754
in gnuplot.
 
755
(Note that the <code>gnuplot_preamble</code> string must be entered without any line breaks.)
 
756
</li></ul>
 
757
<table><tr><td>&nbsp;</td><td><pre class="example">(%i5) my_preamble: &quot;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}' \
 
761
6.283)&quot;$
 
762
 
 
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, &quot;trig.eps&quot;]);
 
766
</pre></td></tr></table>
 
767
<ul>
 
768
<li>
 
769
A three-dimensional plot using the gnuplot pm3d terminal.
 
770
</li></ul>
 
771
<table><tr><td>&nbsp;</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>
 
775
</p>
 
776
<ul>
 
777
<li>
 
778
A three-dimensional plot without a mesh and with contours
 
779
projected on the bottom plane.
 
780
</li></ul>
 
781
<table><tr><td>&nbsp;</td><td><pre class="example">(%i8) my_preamble: &quot;set pm3d at s;unset surface;set contour;\
 
782
set cntrparam levels 20;unset key&quot;$
 
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>
 
788
</p>
 
789
<ul>
 
790
<li>
 
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.)
 
793
</li></ul>
 
794
<table><tr><td>&nbsp;</td><td><pre class="example">(%i10) plot3d (cos (-x^2 + y^3/4), [x, -4, 4], [y, -4, 4],
 
795
    [gnuplot_preamble, &quot;set view map; unset surface&quot;],
 
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>
 
799
</p>
 
800
</dd></dl>
 
801
 
 
802
<dl>
 
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>
 
805
</dt>
 
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>
 
808
</dt>
 
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>
 
811
</dt>
 
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>
 
814
</dt>
 
815
<dd><p>Displays a plot of one or three expressions as functions of two variables.
 
816
</p>
 
817
<table><tr><td>&nbsp;</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>
 
820
</p>
 
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
 
823
axis.
 
824
</p>
 
825
<p>The same graph can be plotted using openmath:
 
826
</p>
 
827
<table><tr><td>&nbsp;</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>
 
831
</p>
 
832
 
 
833
<p>in this case the mouse can be used to rotate the plot to look at the surface
 
834
from different sides.
 
835
</p>
 
836
<p>An example of the third pattern of arguments is
 
837
</p>
 
838
<table><tr><td>&nbsp;</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>
 
842
</p>
 
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
 
846
y direction.
 
847
</p>
 
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.
 
857
</p>
 
858
<p>This example shows a plot of the real part of <code>z^1/3</code>.
 
859
</p>
 
860
<table><tr><td>&nbsp;</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>
 
865
</p>
 
866
 
 
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.
 
872
</p>
 
873
<p>Other examples are the Klein bottle:
 
874
</p>
 
875
<table><tr><td>&nbsp;</td><td><pre class="example">(%i5) expr_1: 5*cos(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)
 
876
      + 3.0) - 10.0$
 
877
(%i6) expr_2: -5*sin(x)*(cos(x/2)*cos(y) + sin(x/2)*sin(2*y)
 
878
      + 3.0)$
 
879
(%i7) expr_3: 5*(-sin(x/2)*cos(y) + cos(x/2)*sin(2*y))$
 
880
 
 
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>
 
885
</p>
 
886
<p>and a torus:
 
887
</p>
 
888
<table><tr><td>&nbsp;</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>
 
895
</p>
 
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.   
 
900
</p>
 
901
<table><tr><td>&nbsp;</td><td><pre class="example">(%i13) M: matrix([1, 2, 3, 4], [1, 2, 3, 2], [1, 2, 3, 4],
 
902
       [1, 2, 3, 3])$
 
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>
 
907
</p>
 
908
<p>See <code>plot_options</code> for more examples.
 
909
</p>
 
910
</dd></dl>
 
911
 
 
912
 
 
913
<dl>
 
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>
 
916
</dt>
 
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>&nbsp;</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.
 
921
</p></dd></dl>
 
922
 
 
923
<dl>
 
924
<dt><u>Function:</u> <b>plot2d_ps</b><i> (<var>expr</var>, <var>range</var>)</i>
 
925
<a name="IDX255"></a>
 
926
</dt>
 
927
<dd><p>Writes to pstream a sequence of PostScript commands which
 
928
plot <var>expr</var> over <var>range</var>.
 
929
</p>
 
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>.
 
933
</p>
 
934
<p>See also <code>closeps</code>.
 
935
</p>
 
936
</dd></dl>
 
937
 
 
938
 
 
939
<dl>
 
940
<dt><u>Function:</u> <b>closeps</b><i> ()</i>
 
941
<a name="IDX256"></a>
 
942
</dt>
 
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.
 
950
</p></dd></dl>
 
951
 
 
952
<dl>
 
953
<dt><u>Function:</u> <b>set_plot_option</b><i> (<var>option</var>)</i>
 
954
<a name="IDX257"></a>
 
955
</dt>
 
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.
 
960
</p>
 
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).
 
964
</p>
 
965
<p>See also <code>plot_options</code>, <code>plot2d</code>, and <code>plot3d</code>.
 
966
</p>
 
967
<p>Examples:
 
968
</p>
 
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.
 
972
</p>
 
973
 
 
974
<table><tr><td>&nbsp;</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]]
 
989
(%i2) x: 42;
 
990
(%o2)                          42
 
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>
 
1007
</dd></dl>
 
1008
 
 
1009
<dl>
 
1010
<dt><u>Function:</u> <b>psdraw_curve</b><i> (<var>ptlist</var>)</i>
 
1011
<a name="IDX258"></a>
 
1012
</dt>
 
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>
 
1015
</p>
 
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.
 
1018
</p>
 
1019
<p><var>psdraw_curve</var> simply invokes the more primitive function
 
1020
<var>pscurve</var>.   Here is the definition:
 
1021
</p>
 
1022
<table><tr><td>&nbsp;</td><td><pre class="example">(defun $psdraw_curve (lis)
 
1023
  (p &quot;newpath&quot;)
 
1024
  ($pscurve lis)
 
1025
  (p &quot;stroke&quot;))
 
1026
 
 
1027
</pre></td></tr></table>
 
1028
 
 
1029
 
 
1030
</dd></dl>
 
1031
 
 
1032
<dl>
 
1033
<dt><u>Function:</u> <b>pscom</b><i> (<var>cmd</var>)</i>
 
1034
<a name="IDX259"></a>
 
1035
</dt>
 
1036
<dd><p><var>cmd</var> is inserted in the PostScript file.
 
1037
Example:
 
1038
</p><table><tr><td>&nbsp;</td><td><pre class="example">pscom (&quot;4.5 72 mul 5.5 72 mul translate 14 14 scale&quot;);
 
1039
</pre></td></tr></table>
 
1040
</dd></dl>
 
1041
 
 
1042
 
 
1043
 
 
1044
 
 
1045
<hr size="6">
 
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"> &lt;&lt; </a>]</td>
 
1048
<td valign="middle" align="left">[<a href="maxima_9.html#SEC35" title="Next chapter"> &gt;&gt; </a>]</td>
 
1049
<td valign="middle" align="left"> &nbsp; </td>
 
1050
<td valign="middle" align="left"> &nbsp; </td>
 
1051
<td valign="middle" align="left"> &nbsp; </td>
 
1052
<td valign="middle" align="left"> &nbsp; </td>
 
1053
<td valign="middle" align="left"> &nbsp; </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>
 
1058
</tr></table>
 
1059
<p>
 
1060
 <font size="-1">
 
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>.
 
1062
 </font>
 
1063
 <br>
 
1064
 
 
1065
</p>
 
1066
</body>
 
1067
</html>