[288710]: maxima-gnuplot.xml Maximize Restore History

Download this file

maxima-gnuplot.xml    137 lines (89 with data), 6.7 kB

  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
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="main.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" id="maxima-gnuplot" xml:lang="en">
<head>
<title>Examples of the Maxima Gnuplot interface</title>
<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
<link rel="schema.DCTERMS" href="http://purl.org/dc/terms/"/>
<meta name="DC.identifier" scheme="DCTERMS.URI" content="http://maxima.sourceforge.net/maxima-gnuplot.html"/>
</head>
<body>
<h3 style="margin-top: 0; padding-top: 0">Basic usage</h3>
<p>The Maxima-Gnuplot interface offers three terminal choices: <em>default</em>, <em>ps</em> and <em>dumb</em>.</p>
<pre>plot2d(sin(x),[x,0,2*%pi]);</pre>
<p><img src="i/plotting/sin-screenshot.png" alt="sin(x) plot" /></p>
<pre>plot2d(sin(x),[x,0,2*%pi],[gnuplot_term,ps],[gnuplot_out_file,"sin.eps"]);</pre>
<p><a href="i/plotting/sin.eps"><img src="i/plotting/sin.png" alt="sin(x) plot" /></a></p>
<p><em>Click on the above image to see The actual postscript file</em>.</p>
<pre>plot2d(sin(x),[x,0,2*%pi],[gnuplot_term,dumb]);
1 ++--------+--$$$$$$$+---------+---------+---------+---------+--------++
+ $$$ $$$ + + + SIN(x) $$$$$$ +
| $$$ $$ |
| $$ $$$ |
0.5 ++ $$ $$ ++
| $$ $$ |
| $$ $$ |
| $$ $$ |
|$$ $$ |
0 $+ $$ $$ ++
| $$ $$ |
| $$ $$ |
| $$ $$ |
-0.5 ++ $$ $$ ++
| $$ $ |
| $$ $$ |
| $$ $$$ |
+ + + + +$$$$ +$$$ + +
-1 ++--------+---------+---------+---------+---$$$$$$$---------+--------++
0 1 2 3 4 5 6 7</pre>
<p>Those of us who remember when ���vt100��� was not just a menu item in a terminal editor, but an actual thing that would hurt to drop on your foot, should find the following picture nostalgic.</p>
<p><img src="i/plotting/sin-nostalgic.png" alt="sin(x) nostalgic plot" /></p>
<h3>More advanced usage</h3>
<p>The adaptive plotting routines (based on an algorithm from <a href="http://yacas.sourceforge.net/">Yacas</a>) allow plotting of functions with singularities.</p>
<pre>plot2d([gamma(x),1/gamma(x)],[x,-4.5,5],[y,-10,10],
[gnuplot_preamble,"set key bottom"]);</pre>
<p><img src="i/plotting/gamma-screenshot.png" alt="gamma(x) and 1/gamma(x) plots" /></p>
<p>It is now possible to take advantage of the advanced features of Gnuplot. Note the tick labels on the horizontal axis in the following figure.</p>
<pre>plot2d([cos(x),sin(x),tan(x),cot(x)],[x,-2*%pi,2*%pi],[y,-2,2],
[gnuplot_preamble,"set xzeroaxis; set xtics ('-2pi' -6.283, '-3pi/2' -4.712,
'-pi' -3.1415, '-pi/2' -1.5708, '0' 0,'pi/2' 1.5708, 'pi' 3.1415,'3pi/2' 4.712,
'2pi' 6.283)"]);</pre>
<p><img src="i/plotting/trig-screenshot.png" alt="cos(x), sin(x), tan(x), cot(x) plots" /></p>
<p>The postscript version of the previous figure can take advantage of Gnuplot's enhanced postscript terminal.</p>
<pre>plot2d([cos(x),sin(x),tan(x)],[x,-2*%pi,2*%pi],[y,-2,2],[gnuplot_preamble,"set
xzeroaxis; set xtics ('-2{/Symbol p}' -6.283, '-3{/Symbol p}/2' -4.712,
'-{/Symbol p}' -3.1415, '-{/Symbol p}/2' -1.5708, '0' 0,'{/Symbol p}/2' 1.5708,
'{/Symbol p}' 3.1415,'3{/Symbol p}/2' 4.712, '2{/Symbol p}'
6.283)"],[gnuplot_term,ps],[gnuplot_out_file,"trig.eps"]);</pre>
<p><a href="i/plotting/trig.eps"><img src="i/plotting/trig.png" alt="cos(x), sin(x), tan(x) plots" /></a></p>
<p>Click on the above image to see the actual postscript file.</p>
<h3>3D plotting and pm3d</h3>
<h4 style="margin-top: 0; padding-top: 0">Plotting without pm3d</h4>
<p>The default three-dimensional plotting generates a mesh. It works with all versions of Gnuplot.</p>
<pre>plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50]);</pre>
<p><img src="i/plotting/surface.png" alt="atan(-x^2+y^3/4) plot" /></p>
<h4>Plotting with pm3d</h4>
<p>Gnuplot 4.0 includes pm3d, which provides many advanced options for three- and four-dimensional plotting. Use of pm3d is turned off by default because Gnuplot 4.0 is not yet commonly installed. If Gnuplot 4.0 is installed, Maxima can take advantage of the features in pm3d.</p>
<p>The default plot with pm3d includes a mesh and a colored surface.</p>
<pre>plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]);</pre>
<p><img src="i/plotting/surface-pm3d.png" alt="atan(-x^2+y^3/4) plot" /></p>
<p>Several variations are possible. Here is one with no mesh and contours on at the base.</p>
<pre>plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true],[gnup
lot_preamble,"set pm3d at s;unset surface;set contour;set cntrparam levels
20;unset key"]);</pre>
<p><img src="i/plotting/surface-pm3d-1.png" alt="atan(-x^2+y^3/4) plot" /></p>
<p>The following variation includes the mesh and puts the colors on the base.</p>
<pre>surface-pm3d-2:
plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true],[gnup
lot_preamble,"set pm3d at b"]);</pre>
<p><img src="i/plotting/surface-pm3d-2.png" alt="atan(-x^2+y^3/4) plot" /></p>
<p>Some functions are too complicated to be practically visualized with a mesh.</p>
<pre>plot3d(cos(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,150,150]);</pre>
<p><img src="i/plotting/badsurface.png" alt="cos(-x^2+y^3/4) plot" /></p>
<p>However, the above function can be effectively visualized using pm3d's ���map view���.</p>
<pre>plot3d(cos(-x^2+y^3/4),[x,-4,4],[y,-4,4],[gnuplot_preamble,"set view map;
unset surface"],[gnuplot_pm3d,true],[grid,150,150]);</pre>
<p><img src="i/plotting/map.png" alt="cos(-x^2+y^3/4) plot" /></p>
</body>
</html>