Maxima 的绘图功能 3
最后更新于:2022-04-01 07:31:13
本文最初写于 2011-07-03于 sohu 博客,这次博客搬家一起搬到这里来。
版权所有,转载请注明出处。
1.3 二维参数方程绘图
如果在函数列表之前加上 parametric,就代表参数方程作图。
nticks 参数控制画图时函数计算取样的数目。如果这个值过小,可能画出的函数曲线不够平滑。
| (%i1) | wxplot2d([parametric, sin(t), cos(t)/2], [t, - %pi, %pi], [nticks, 10]); |
|-----|-----|

默认的nticks = 10, 只有十个点得到的图形失真很严重。将 nticks 加大到 200 后曲线变的光滑的多。
| (%i2) | wxplot2d([parametric, sin(t), cos(t)/2], [t, - %pi, %pi], [nticks, 200]); |
|-----|-----|

下面用参数方程绘制出蝴蝶曲线。
<table><tbody><tr><td><span>(%i3) </span></td><td><span>r: (exp(cos(t))-2*cos(4*t)-sin(t/12)^5)$<br/>wxplot2d([parametric, r*sin(t), r*cos(t), [t, -8*%pi, 8*%pi], [nticks, 2000]])$ </span></td></tr></tbody></table>

同样,参数方程也可以和其他类型的曲线绘制于同一幅图中。下面的例子用到了各种常见选项。
<table><tbody><tr><td><span>(%i9) </span></td><td><span>wxplot2d([[parametric, 5*sin(t), 6*cos(t)], [discrete,xx,yy]], <br/>[t, 0, %pi], [nticks, 200],[style, [lines, 1, 2], [points, 3, 1, 11]],<br/> [legend, "parametric", "discrete"],[xlabel, "time"], [ylabel, "position(m)"]); </span></td></tr></tbody></table>

数据点还可以在一个列表中,下面是一个例子:
<table><tbody><tr><td><span>(%i10) </span></td><td><span>xy: [[10, .6], [20, .9], [30, 1.1], [40, 1.3], [50, 1.4]]$<br/>wxplot2d([[discrete, xy], 2*%pi*sqrt(l/980)], [l,0,50],<br/> [style, points, lines], [color, red, blue], [point_type, asterisk],<br/> [legend, "experiment", "theory"],<br/> [xlabel, "pendulum's length (cm)"], [ylabel, "period (s)"])$ </span></td></tr></tbody></table>

等高线绘图
contour_plot (x^2 + y^2, [x, -4, 4], [y, -4, 4])$

contour_plot (u^3 + v^2, [u, -4, 4], [v, -4, 4],
[legend,false], [grid, 500, 500],
[gnuplot_preamble,"set cntrparam levels 22"])$

wxcontour_plot (x*sin(y)+y*sin(x), [x, -10, 10], [y, -10, 10],
[legend,false], [grid, 100, 100],
[gnuplot_preamble,"set pm3d; set cntrparam levels 30"])$
