1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima 5.45.1 Manual: Functions and Variables for Plotting</title>
<meta name="description" content="Maxima 5.45.1 Manual: Functions and Variables for Plotting">
<meta name="keywords" content="Maxima 5.45.1 Manual: Functions and Variables for Plotting">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="maxima_0.html#Top" rel="start" title="Top">
<link href="maxima_368.html#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_61.html#Plotting" rel="up" title="Plotting">
<link href="maxima_65.html#Plotting-Options" rel="next" title="Plotting Options">
<link href="maxima_63.html#Plotting-Formats" rel="previous" title="Plotting Formats">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white; margin-left: 8%; margin-right: 13%;
font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
font-family: sans-serif}
div.synopsisbox {
border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 0px; padding-bottom: 0px;
padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}
-->
</style>
<link rel="icon" href="figures/favicon.ico">
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Functions-and-Variables-for-Plotting"></a>
<div class="header">
<p>
Next: <a href="maxima_65.html#Plotting-Options" accesskey="n" rel="next">Plotting Options</a>, Previous: <a href="maxima_63.html#Plotting-Formats" accesskey="p" rel="previous">Plotting Formats</a>, Up: <a href="maxima_61.html#Plotting" accesskey="u" rel="up">Plotting</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_368.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Functions-and-Variables-for-Plotting-1"></a>
<h3 class="section">12.3 Functions and Variables for Plotting</h3>
<a name="geomview_005fcommand"></a><a name="Item_003a-Plotting_002fdefvr_002fgeomview_005fcommand"></a><dl>
<dt><a name="index-geomview_005fcommand"></a>System variable: <strong>geomview_command</strong></dt>
<dd>
<p>This variable stores the name of the command used to run the geomview
program when the plot format is <code>geomview</code>. Its default value is
"geomview". If the geomview program is not found unless you give
its complete path or if you want to try a different version of it,
you may change the value of this variable. For instance,
</p>
<div class="example">
<pre class="example">(%i1) geomview_command: "/usr/local/bin/my_geomview"$
</pre></div>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="get_005fplot_005foption"></a><a name="Item_003a-Plotting_002fdeffn_002fget_005fplot_005foption"></a><dl>
<dt><a name="index-get_005fplot_005foption"></a>Function: <strong>get_plot_option</strong> <em>(<var>keyword</var>, <var>index</var>)</em></dt>
<dd>
<p>Returns the current default value of the option named <var>keyword</var>,
which is a list. The optional argument <var>index</var> must be a positive
integer which can be used to extract only one element from the list
(element 1 is the name of the option).
</p>
<p>See also <code><a href="#set_005fplot_005foption">set_plot_option</a></code>, <code><a href="#remove_005fplot_005foption">remove_plot_option</a></code> and the
section on <code><a href="maxima_65.html#Plotting-Options">Plotting Options</a></code>.
</p></dd></dl>
<a name="gnuplot_005fcommand"></a><a name="Item_003a-Plotting_002fdefvr_002fgnuplot_005fcommand"></a><dl>
<dt><a name="index-gnuplot_005fcommand"></a>System variable: <strong>gnuplot_command</strong></dt>
<dd>
<p>This variable stores the name of the command used to run the gnuplot
program when the plot format is <code>gnuplot</code> or
<code>gnuplot_pipes</code>. Its default value is "gnuplot". If the gnuplot
program is not found unless you give its complete path or if you want to
try a different version of it, you may change the value of this
variable. For instance,
</p>
<div class="example">
<pre class="example">(%i1) gnuplot_command: "/usr/local/bin/my_gnuplot"$
</pre></div>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="gnuplot_005ffile_005fargs"></a><a name="Item_003a-Plotting_002fdefvr_002fgnuplot_005ffile_005fargs"></a><dl>
<dt><a name="index-gnuplot_005ffile_005fargs"></a>System variable: <strong>gnuplot_file_args</strong></dt>
<dd>
<p>When a graphic file is going to be created using <code>gnuplot</code>, this
variable is used to specify the format used to print the file name given
to gnuplot. Its default value is "~a" in SBCL and Openmcl, and "~s" in
other lisp versions, which means that the name of the file will be
passed without quotes if SBCL or Openmcl are used and within quotes if
other Lisp versions are used. The contents of this variable can be
changed in order to add options for the gnuplot program, adding those
options before the format directive "~s".
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="gnuplot_005fview_005fargs"></a><a name="Item_003a-Plotting_002fdefvr_002fgnuplot_005fview_005fargs"></a><dl>
<dt><a name="index-gnuplot_005fview_005fargs"></a>System variable: <strong>gnuplot_view_args</strong></dt>
<dd>
<p>This variable is the format used to parse the argument that will be
passed to the gnuplot program when the plot format is
<code>gnuplot</code>. Its default value is "-persist ~a" when SBCL or Openmcl
are used, and "-persist ~s" with other Lisp variants, where "~a" or "~s"
will be replaced with the name of the file where the gnuplot commands
have been written (usually "maxout_xxx.gnuplot"). The option
<code>-persist</code> tells gnuplot to exit after the commands in the file
have been executed, without closing the window that displays the plot.
</p>
<p>Those familiar with gnuplot, might want to change the value of this
variable. For example, by changing it to:
</p>
<div class="example">
<pre class="example">(%i1) gnuplot_view_args: "~s -"$
</pre></div>
<p>gnuplot will not be closed after the commands in the file have been
executed; thus, the window with the plot will remain, as well as the
gnuplot interactive shell where other commands can be issued in order to
modify the plot.
</p>
<p>In Windows versions of Gnuplot older than 4.6.3 the behavior of "~s -"
and "-persist ~s" were the opposite; namely, "-persist ~s" made the plot
window and the gnuplot interactive shell remain, while "~s -" closed the
gnuplot shell keeping the plot window. Therefore, when older gnuplot
versions are used in Windows, it might be necessary to adjust the value
of <code>gnuplot_view_args</code>.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="julia"></a><a name="Item_003a-Plotting_002fdeffn_002fjulia"></a><dl>
<dt><a name="index-julia"></a>Function: <strong>julia</strong> <em>(<var>x</var>, <var>y</var>, ...<var>options</var>...)</em></dt>
<dd>
<p>Creates a graphic representation of the Julia set for the complex number
(<var>x</var> + i <var>y</var>). The two mandatory parameters <var>x</var> and <var>y</var>
must be real. This program is part of the additional package
<code>dynamics</code>, but that package does not have to be loaded; the first
time julia is used, it will be loaded automatically.
</p>
<p>Each pixel in the grid is given a color corresponding to the number of
iterations it takes the sequence that starts at that point to move out
of the convergence circle of radius 2 centered at the origin. The number
of pixels in the grid is controlled by the <code><a href="maxima_65.html#grid">grid</a></code> plot option
(default 30 by 30). The maximum number of iterations is set with the
option <code><a href="maxima_65.html#iterations">iterations</a></code>. The program sets its own default palette:
magenta, violet, blue, cyan, green, yellow, orange, red, brown and black,
but it can be changed by adding an explicit <code><a href="maxima_65.html#palette">palette</a></code> option in the
command.
</p>
<p>The default domain used goes from -2 to 2 in both axes and can be
changed with the <code>x</code> and <code>y</code> options. By default, the two axes
are shown with the same scale, unless the option <code><a href="maxima_65.html#yx_005fratio">yx_ratio</a></code> is used
or the option <code><a href="maxima_65.html#same_005fxy">same_xy</a></code> is disabled. Other general plot options are
also accepted.
</p>
<p>The following example shows a region of the Julia set for the number
-0.55 + i0.6. The option <code><a href="maxima_65.html#color_005fbar_005ftics">color_bar_tics</a></code> is used to prevent
Gnuplot from adjusting the color box up to 40, in which case the points
corresponding the maximum 36 iterations would not be black.
</p>
<div class="example">
<pre class="example">(%i1) julia (-0.55, 0.6, [iterations, 36], [x, -0.3, 0.2],
[y, 0.3, 0.9], [grid, 400, 400], [color_bar_tics, 0, 6, 36])$
</pre></div>
<img src="figures/plotting4.png" alt="figures/plotting4">
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Package-dynamics">Package dynamics</a>
·<a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p>
</dd></dl>
<a name="make_005ftransform"></a><a name="Item_003a-Plotting_002fdeffn_002fmake_005ftransform"></a><dl>
<dt><a name="index-make_005ftransform"></a>Function: <strong>make_transform</strong> <em>([<var>var1</var>, <var>var2</var>, <var>var3</var>], <var>fx</var>, <var>fy</var>, <var>fz</var>)</em></dt>
<dd>
<p>Returns a function suitable to be used in the option <code><a href="maxima_65.html#transform_005fxy">transform_xy</a></code><!-- /@w -->
of plot3d. The three variables <var>var1</var>, <var>var2</var>, <var>var3</var> are
three dummy variable names, which represent the 3 variables given by the
plot3d command (first the two independent variables and then the
function that depends on those two variables). The three functions
<var>fx</var>, <var>fy</var>, <var>fz</var> must depend only on those 3 variables, and
will give the corresponding x, y and z coordinates that should be
plotted. There are two transformations defined by default:
<code><a href="#polar_005fto_005fxy">polar_to_xy</a></code> and <code><a href="#spherical_005fto_005fxyz">spherical_to_xyz</a></code>. See the documentation
for those two transformations.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="mandelbrot"></a><a name="Item_003a-Plotting_002fdeffn_002fmandelbrot"></a><dl>
<dt><a name="index-mandelbrot"></a>Function: <strong>mandelbrot</strong> <em>(<var>options</var>)</em></dt>
<dd>
<p>Creates a graphic representation of the Mandelbrot set. This program is
part of the additional package <code>dynamics</code>, but that package does
not have to be loaded; the first time mandelbrot is used, the package
will be loaded automatically.
</p>
<p>This program can be called without any arguments, in which case it will
use a default value of 9 iterations per point, a grid with dimensions
set by the <code><a href="maxima_65.html#grid">grid</a></code> plot option (default 30 by 30) and a region
that extends from -2 to 2 in both axes. The options are all the same
that plot2d accepts, plus an option <code><a href="maxima_65.html#iterations">iterations</a></code> to change the
number of iterations.
</p>
<p>Each pixel in the grid is given a color corresponding to the number of
iterations it takes the sequence starting at zero to move out
of the convergence circle of radius 2, centered at the origin. The
maximum number of iterations is set by the option <code><a href="maxima_65.html#iterations">iterations</a></code>.
The program uses its own default palette: magenta,violet, blue, cyan,
green, yellow, orange, red, brown and black, but it can be changed by
adding an explicit <code><a href="maxima_65.html#palette">palette</a></code> option in the command. By default, the
two axes are shown with the same scale, unless the option <code><a href="maxima_65.html#yx_005fratio">yx_ratio</a></code>
is used or the option <code><a href="maxima_65.html#same_005fxy">same_xy</a></code> is disabled.
</p>
<p>Example:
</p>
<p>[grid,400,400])$
</p><div class="example">
<pre class="example">(%i1) mandelbrot ([iterations, 30], [x, -2, 1], [y, -1.2, 1.2],
[grid,400,400])$
</pre></div>
<img src="figures/plotting5.png" alt="figures/plotting5">
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Package-dynamics">Package dynamics</a>
·<a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p>
</dd></dl>
<a name="polar_005fto_005fxy"></a><a name="Item_003a-Plotting_002fdeffn_002fpolar_005fto_005fxy"></a><dl>
<dt><a name="index-polar_005fto_005fxy"></a>System function: <strong>polar_to_xy</strong></dt>
<dd>
<p>It can be given as value for the <code><a href="maxima_65.html#transform_005fxy">transform_xy</a></code> option of
plot3d. Its effect will be to interpret the two independent variables in
plot3d as the distance from the z axis and the azimuthal angle (polar
coordinates), and transform them into x and y coordinates.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="plot2d"></a><a name="Item_003a-Plotting_002fdeffn_002fplot2d"></a><dl>
<dt><a name="index-plot2d"></a>Function: <strong>plot2d</strong> <em><br> <tt>plot2d</tt> (<var>expr</var>, <var>range_x</var>, <var>options</var>) <br> <tt>plot2d</tt> (<var>expr_1</var>=<var>expr_2</var>, <var>range_x</var>, <var>range_y</var>, <var>options</var>) <br> <tt>plot2d</tt> ([parametric, <var>expr_x</var>, <var>expr</var>_y, <var>range</var>], <var>options</var>) <br> <tt>plot2d</tt> ([discrete, <var>points</var>], <var>options</var>) <br> <tt>plot2d</tt> ([contour, <var>expr</var>], <var>range_x</var>, <var>range_y</var>, <var>options</var>) <br> <tt>plot2d</tt> ([<var>type_1</var>, …, <var>type_n</var>], <var>options</var>)</em></dt>
<dd>
<p>There are 5 types of plots that can be plotted by <code>plot2d</code>:
</p>
<ol>
<li> <b>Explicit functions</b>. <code>plot2d</code> (<var>expr</var>, <var>range_x</var>,
<var>options</var>), where <var>expr</var> is an expression that depends on only
one variable, or the name of a function with one input parameter and
numerical results. <var>range_x</var> is a list with three elements, the
first one being the name of the variable that will be shown on the
horizontal axis of the plot, and the other two elements should be two
numbers, the first one smaller than the second, that define the minimum
and maximum values to be shown on the horizontal axis. The name of the
variable used in <var>range_x</var> must be the same variable on which
<var>expr</var> depends. The result will show in the vertical axis the
corresponding values of the expression or function for each value of the
variable in the horizontal axis.
</li><li> <b>Implicit functions</b>. <code>plot2d</code> (<var>expr_1</var>=<var>expr_2</var>,
<var>range_x</var>, <var>range_y</var>, <var>options</var>), where <var>expr_1</var> and
<var>expr_2</var> are two expressions that can depend on one or two
variables. <var>range_x</var> and <var>range_y</var> must be two lists of three
elements that define the ranges for the variables in the two axes of the
plot; the first element of each list is the name of the corresponding
variable, and the other two elements are the minimum and maximum values
for that variable. The two variables on which <var>expr_1</var> and
<var>expr_2</var> can depend are those specified by <var>range_x</var> and
<var>range_y</var>. The result will be a curve or a set of curves where the
equation <var>expr_1</var>=<var>expr_2</var> is true.
</li><li> <b>Parametric functions</b>. <code>plot2d</code> ([parametric,
<var>expr_x</var>, <var>expr</var>_y, <var>range</var>], <var>options</var>), where
<var>expr_x</var> and <var>expr</var>_y are two expressions that depend on a
single parameter. <var>range</var> must be a three-element list; the first
element must be the name of the parameter on which <var>expr_x</var> and
<var>expr</var>_y depend, and the other two elements must be the minimum and
maximum values for that parameter. The result will be a curve in which
the horizontal and vertical coordinates of each point are the values of
<var>expr_x</var> and <var>expr</var>_y for a value of the parameter within the
range given.
</li><li> <b>Set of points</b>. <code>plot2d</code> ([discrete, <var>points</var>],
<var>options</var>), displays a list of points, joined by segments by
default. The horizontal and vertical coordinates of each of those points
can be specified in three different ways: With two lists of the same
length, in which the elements of the first list are the horizontal
coordinates of the points and the second list are the vertical
coordinates, or with a list of two-element lists, each one corresponding
to the two coordinates of one of the points, or with a single list that
defines the vertical coordinates of the points; in this last case, the
horizontal coordinates of the n points will be assumed to be the first n
natural numbers.
</li><li> <b>Contour lines</b>. <code>plot2d</code> ([contour, <var>expr</var>],
<var>range_x</var>, <var>range_y</var>, <var>options</var>), where <var>expr</var> is an
expression that depends on two variables. <var>range_x</var> and
<var>range_y</var> will be lists whose first elements are the names of those
two variables, followed by two numbers that set the minimum and maximum
values for them. The first variable will be represented along the
horizontal axis and the second along the vertical axis. The result will
be a set of curves along which the given expression has certain
values. If those values are not specified with the option <code>levels</code>,
plotd2d will try to choose, at the most, 8 values of the form d*10^n, where d is
either 1, 2 or 5, all of them within the minimum and maximum values of
<var>expr</var> within the given ranges.
</li></ol>
<p>At the end of a plot2d command several of the options described in
<code><a href="maxima_65.html#Plotting-Options">Plotting Options</a></code> can be used. Many instances of the 5 types
described above can be combined into a single plot, by putting them
inside a list: <code>plot2d</code> ([<var>type_1</var>, …, <var>type_n</var>],
<var>options</var>). If one of the types included in the list require
<var>range_x</var> or <var>range_y</var>, those ranges should come immediately
after the list.
</p>
<p>If there are several plots to be plotted, a legend will be
written to identity each of the expressions. The labels that should be
used in that legend can be given with the option <code><a href="maxima_65.html#legend">legend</a></code>. If that
option is not used, Maxima will create labels from the expressions or
function names.
</p>
<p><strong>Examples:</strong>
</p>
<ol>
<li> Explicit function.
<div class="example">
<pre class="example">(%i1) plot2d (sin(x), [x, -%pi, %pi])$
</pre></div>
<img src="figures/plotting6.png" alt="figures/plotting6">
</li><li> Implicit function.
<div class="example">
<pre class="example">(%i1) plot2d (x^2-y^3+3*y=2, [x,-2.5,2.5], [y,-2.5,2.5])$
</pre></div>
<img src="figures/plotting3.png" alt="figures/plotting3">
</li><li> Parametric function.
<div class="example">
<pre class="example">(%i1) r: (exp(cos(t))-2*cos(4*t)-sin(t/12)^5)$
(%i2) plot2d([parametric, r*sin(t), r*cos(t), [t,-8*%pi,8*%pi]])$
</pre></div>
<img src="figures/plotting11.png" alt="figures/plotting11">
</li><li> Set of points.
<div class="example">
<pre class="example">(%i1) plot2d ([discrete, makelist(i*%pi, i, 1, 5),
[0.6, 0.9, 0.2, 1.3, 1]])$
</pre></div>
<img src="figures/plotting14.png" alt="figures/plotting14">
</li><li> Contour lines.
<div class="example">
<pre class="example">(%i1) plot2d ([contour, u^3 + v^2], [u, -4, 4], [v, -4, 4])$
</pre></div>
<img src="figures/plotting2.png" alt="figures/plotting2">
</li></ol>
<p><strong>Examples using options</strong>.
</p>
<p>If an explicit function grows too fast, the <code><a href="maxima_65.html#y">y</a></code> option can be used
to limit the values in the vertical axis:
</p>
<div class="example">
<pre class="example">(%i1) plot2d (sec(x), [x, -2, 2], [y, -20, 20])$
</pre></div>
<img src="figures/plotting7.png" alt="figures/plotting7">
<p>When the plot box is disabled, no labels are created for the axes. In
that case, instead of using <code><a href="maxima_65.html#xlabel">xlabel</a></code> and <code><a href="maxima_65.html#ylabel">ylabel</a></code> to set the
names of the axes, it is better to use option <code><a href="maxima_65.html#label">label</a></code>, which
allows more flexibility. Option <code><a href="maxima_65.html#yx_005fratio">yx_ratio</a></code> is used to change the
default rectangular shape of the plot; in this example the plot will
fill a square.
</p>
<div class="example">
<pre class="example">(%i1) plot2d ( x^2 - 1, [x, -3, 3], nobox, grid2d,
[yx_ratio, 1], [axes, solid], [xtics, -2, 4, 2],
[ytics, 2, 2, 6], [label, ["x", 2.9, -0.3],
["x^2-1", 0.1, 8]], [title, "A parabola"])$
</pre></div>
<img src="figures/plotting8.png" alt="figures/plotting8">
<p>A plot with a logarithmic scale in the vertical axis:
</p>
<div class="example">
<pre class="example">(%i1) plot2d (exp(3*s), [s, -2, 2], logy)$
</pre></div>
<img src="figures/plotting9.png" alt="figures/plotting9">
<p>Plotting functions by name:
</p>
<div class="example">
<pre class="example">(%i1) F(x) := x^2 $
(%i2) :lisp (defun |$g| (x) (m* x x x))
$g
(%i2) H(x) := if x < 0 then x^4 - 1 else 1 - x^5 $
(%i3) plot2d ([F, G, H], [u, -1, 1], [y, -1.5, 1.5])$
</pre></div>
<img src="figures/plotting10.png" alt="figures/plotting10">
<p>Plot of a circle, using its parametric representation, together with the
function -<code>|<var>x</var>|</code>. The circle will only look like a circle if
the scale in the two axes is the same, which is done with the option
<code><a href="maxima_65.html#same_005fxy">same_xy</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) plot2d([[parametric, cos(t), sin(t), [t,0,2*%pi]], -abs(x)],
[x, -sqrt(2), sqrt(2)], same_xy)$
</pre></div>
<img src="figures/plotting12.png" alt="figures/plotting12">
<p>A plot of 200 random numbers between 0 and 9:
</p>
<div class="example">
<pre class="example">(%i1) plot2d ([discrete, makelist ( random(10), 200)])$
</pre></div>
<img src="figures/plotting13.png" alt="figures/plotting13">
<p>In the next example a table with three columns is saved in a file
“data.txt” which is then read and the second and third column are
plotted on the two axes:
</p>
<div class="example">
<pre class="example">(%i1) display2d:false$
(%i2) with_stdout ("data.txt", for x:0 thru 10 do
print (x, x^2, x^3))$
(%i3) data: read_matrix ("data.txt")$
(%i4) plot2d ([discrete, transpose(data)[2], transpose(data)[3]],
[style,points], [point_type,diamond], [color,red])$
</pre></div>
<img src="figures/plotting15.png" alt="figures/plotting15">
<p>A plot of discrete data points together with a continuous function:
</p>
<div class="example">
<pre class="example">(%i1) xy: [[10, .6], [20, .9], [30, 1.1], [40, 1.3], [50, 1.4]]$
(%i2) plot2d([[discrete, xy], 2*%pi*sqrt(l/980)], [l,0,50],
[style, points, lines], [color, red, blue],
[point_type, asterisk],
[legend, "experiment", "theory"],
[xlabel, "pendulum's length (cm)"],
[ylabel, "period (s)"])$
</pre></div>
<img src="figures/plotting16.png" alt="figures/plotting16">
<p>See also the section about Plotting Options.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="plot3d"></a><a name="Item_003a-Plotting_002fdeffn_002fplot3d"></a><dl>
<dt><a name="index-plot3d"></a>Function: <strong>plot3d</strong> <em><br> <tt>plot3d</tt> (<var>expr</var>, <var>x_range</var>, <var>y_range</var>, …, <var>options</var>, …) <br> <tt>plot3d</tt> ([<var>expr_1</var>, …, <var>expr_n</var>], <var>x_range</var>, <var>y_range</var>, …, <var>options</var>, …)</em></dt>
<dd>
<p>Displays a plot of one or more surfaces defined as functions of two
variables or in parametric form.
</p>
<p>The functions to be plotted may be specified as expressions or function names.
The mouse can be used to rotate the plot looking at the surface from different
sides.
</p>
<p><strong>Examples</strong>.
</p>
<p>Plot of a function of two variables:
</p>
<div class="example">
<pre class="example">(%i1) plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100],
nomesh_lines)$
</pre></div>
<img src="figures/plotting17.png" alt="figures/plotting17">
<p>Use of the <code><a href="maxima_65.html#z">z</a></code> option to limit a function that goes to infinity
(in this case the function is minus infinity on the x and y axes); this also
shows how to plot with only lines and no shading:
</p>
<div class="example">
<pre class="example">(%i1) plot3d ( log ( x^2*y^2 ), [x, -2, 2], [y, -2, 2], [z, -8, 4],
nopalette, [color, magenta])$
</pre></div>
<img src="figures/plotting18.png" alt="figures/plotting18">
<p>The infinite values of z can also be avoided by choosing a grid that
does not fall on any points where the function is undefined, as in the
next example, which also shows how to change the palette and how to
include a color bar that relates colors to values of the z variable:
</p>
<div class="example">
<pre class="example">(%i1) plot3d (log (x^2*y^2), [x, -2, 2], [y, -2, 2],[grid, 29, 29],
[palette, [gradient, red, orange, yellow, green]],
color_bar, [xtics, 1], [ytics, 1], [ztics, 4],
[color_bar_tics, 4])$
</pre></div>
<img src="figures/plotting19.png" alt="figures/plotting19">
<p>Two surfaces in the same plot. Ranges specific to one of the surfaces can
be given by placing each expression and its ranges in a separate list;
global ranges for the complete plot are also given after the function
definitions.
</p>
<div class="example">
<pre class="example">(%i1) plot3d ([[-3*x - y, [x, -2, 2], [y, -2, 2]],
4*sin(3*(x^2 + y^2))/(x^2 + y^2), [x, -3, 3], [y, -3, 3]],
[x, -4, 4], [y, -4, 4])$
</pre></div>
<img src="figures/plotting20.png" alt="figures/plotting20">
<p>Plot of a Klein bottle, defined parametrically:
</p>
<div class="example">
<pre class="example">(%i1) expr_1: 5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3)-10$
(%i2) expr_2: -5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3)$
(%i3) expr_3: 5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))$
(%i4) plot3d ([expr_1, expr_2, expr_3], [x, -%pi, %pi],
[y, -%pi, %pi], [grid, 50, 50])$
</pre></div>
<img src="figures/plotting21.png" alt="figures/plotting21">
<p>Plot of a “spherical harmonic” function, using the predefined
transformation, <code>spherical_to_xyz</code> to transform from spherical
coordinates to rectangular coordinates. See the documentation for
<code><a href="#spherical_005fto_005fxyz">spherical_to_xyz</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) plot3d (sin(2*theta)*cos(phi), [theta,0,%pi], [phi,0,2*%pi],
[transform_xy, spherical_to_xyz], [grid, 30, 60], nolegend)$
</pre></div>
<img src="figures/plotting22.png" alt="figures/plotting22">
<p>Use of the pre-defined function <code>polar_to_xy</code> to transform from
cylindrical to rectangular coordinates. See the documentation for
<code><a href="#polar_005fto_005fxy">polar_to_xy</a></code>.
</p>
<div class="example">
<pre class="example">(%i1) plot3d (r^.33*cos(th/3), [r,0,1], [th,0,6*%pi], nobox,
nolegend, [grid, 12, 80], [transform_xy, polar_to_xy])$
</pre></div>
<img src="figures/plotting23.png" alt="figures/plotting23">
<p>Plot of a sphere using the transformation from spherical to rectangular
coordinates. Option <code><a href="maxima_65.html#same_005fxyz">same_xyz</a></code> is used to get the three axes
scaled in the same proportion. When transformations are used, it is not
convenient to eliminate the mesh lines, because Gnuplot will not show the
surface correctly.
</p>
<div class="example">
<pre class="example">(%i1) plot3d ( 5, [theta,0,%pi], [phi,0,2*%pi], same_xyz, nolegend,
[transform_xy, spherical_to_xyz], [mesh_lines_color,blue],
[palette,[gradient,"#1b1b4e", "#8c8cf8"]])$
</pre></div>
<img src="figures/plotting24.png" alt="figures/plotting24">
<p>Definition of a function of two-variables using a matrix. Notice the
single quote in the definition of the function, to prevent <code>plot3d</code>
from failing when it realizes that the matrix will require integer
indices.
</p>
<div class="example">
<pre class="example">(%i1) M: matrix([1,2,3,4], [1,2,3,2], [1,2,3,4], [1,2,3,3])$
(%i2) f(x, y) := float('M [round(x), round(y)])$
(%i3) plot3d (f(x,y), [x,1,4], [y,1,4], [grid,3,3], nolegend)$
</pre></div>
<img src="figures/plotting25.png" alt="figures/plotting25">
<p>By setting the elevation equal to zero, a surface can be seen as a map
in which each color represents a different level.
</p>
<div class="example">
<pre class="example">(%i1) plot3d (cos (-x^2 + y^3/4), [x,-4,4], [y,-4,4], [zlabel,""],
[mesh_lines_color,false], [elevation,0], [azimuth,0],
color_bar, [grid,80,80], noztics, [color_bar_tics,1])$
</pre></div>
<img src="figures/plotting26.png" alt="figures/plotting26">
<p>See also <code><a href="maxima_65.html#Plotting-Options">Plotting Options</a></code>.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="plot_005foptions"></a><a name="Item_003a-Plotting_002fdefvr_002fplot_005foptions"></a><dl>
<dt><a name="index-plot_005foptions"></a>System variable: <strong>plot_options</strong></dt>
<dd>
<p>This option is being kept for compatibility with older versions, but its
use is deprecated. To set global plotting options, see their current
values or remove options, use <code><a href="#set_005fplot_005foption">set_plot_option</a></code>,
<code><a href="#get_005fplot_005foption">get_plot_option</a></code> and <code><a href="#remove_005fplot_005foption">remove_plot_option</a></code>.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="remove_005fplot_005foption"></a><a name="Item_003a-Plotting_002fdeffn_002fremove_005fplot_005foption"></a><dl>
<dt><a name="index-remove_005fplot_005foption"></a>Function: <strong>remove_plot_option</strong> <em>(<var>name</var>)</em></dt>
<dd>
<p>Removes the default value of an option. The name of the option must be given.
</p>
<p>See also <code><a href="#set_005fplot_005foption">set_plot_option</a></code>, <code><a href="#get_005fplot_005foption">get_plot_option</a></code> and
<code><a href="maxima_65.html#Plotting-Options">Plotting Options</a></code>.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="set_005fplot_005foption"></a><a name="Item_003a-Plotting_002fdeffn_002fset_005fplot_005foption"></a><dl>
<dt><a name="index-set_005fplot_005foption"></a>Function: <strong>set_plot_option</strong> <em>(<var>option</var>)</em></dt>
<dd>
<p>Accepts any of the options listed in the section Plotting Options, and
saves them for use in plotting commands. The values of the options set
in each plotting command will have precedence, but if those options are
not given, the default values set with this function will be used.
</p>
<p><code>set_plot_option</code> evaluates its argument and returns the complete
list of options (after modifying the option given). If called without
any arguments, it will simply show the list of current default options.
</p>
<p>See also <code><a href="#remove_005fplot_005foption">remove_plot_option</a></code>, <code><a href="#get_005fplot_005foption">get_plot_option</a></code> and the section
on Plotting Options.
</p>
<p>Example:
</p>
<p>Modification of the <code><a href="maxima_65.html#grid">grid</a></code> values.
</p>
<div class="example">
<pre class="example">(%i1) set_plot_option ([grid, 30, 40]);
(%o1) [[plot_format, gnuplot_pipes], [grid, 30, 40],
[run_viewer, true], [axes, true], [nticks, 29], [adapt_depth, 5],
[color, blue, red, green, magenta, black, cyan],
[point_type, bullet, box, triangle, plus, times, asterisk],
[palette, [gradient, green, cyan, blue, violet],
[gradient, magenta, violet, blue, cyan, green, yellow, orange,
red, brown, black]], [gnuplot_preamble, ], [gnuplot_term, default]]
</pre></div>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="spherical_005fto_005fxyz"></a><a name="Item_003a-Plotting_002fdeffn_002fspherical_005fto_005fxyz"></a><dl>
<dt><a name="index-spherical_005fto_005fxyz"></a>System function: <strong>spherical_to_xyz</strong></dt>
<dd>
<p>It can be given as value for the <code><a href="maxima_65.html#transform_005fxy">transform_xy</a></code> option of
<code><a href="#plot3d">plot3d</a></code>. Its effect will be to interpret the two independent
variables and the function in <code>plot3d</code> as the spherical coordinates
of a point (first, the angle with the z axis, then the angle of the xy
projection with the x axis and finally the distance from the origin) and
transform them into x, y and z coordinates.
</p>
<div class=categorybox>·<p>Categories: <a href="maxima_369.html#Category_003a-Plotting">Plotting</a>
</div></p></dd></dl>
<a name="Item_003a-Plotting_002fnode_002fPlotting-Options"></a><hr>
<div class="header">
<p>
Next: <a href="maxima_65.html#Plotting-Options" accesskey="n" rel="next">Plotting Options</a>, Previous: <a href="maxima_63.html#Plotting-Formats" accesskey="p" rel="previous">Plotting Formats</a>, Up: <a href="maxima_61.html#Plotting" accesskey="u" rel="up">Plotting</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_368.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|