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
|
Plotting
========
If `matplotlib <https://matplotlib.org/>`_ is available, the functions
:func:`~mpmath.plot` and :func:`~mpmath.cplot` can be used to plot functions
respectively as x-y graphs and in the complex plane. Also,
:func:`~mpmath.splot` can be used to produce 3D surface plots.
Function curve plots
-----------------------
.. plot::
from mpmath import cos, plot, sin
plot([cos, sin], [-4, 4])
.. autofunction:: mpmath.plot
Complex function plots
-------------------------
.. plot::
from mpmath import cplot, fp
fp.cplot(fp.gamma, points=100000)
.. autofunction:: mpmath.cplot
3D surface plots
----------------
.. plot::
from mpmath import cos, pi, sin, splot
r, R = 1, 2.5
f = lambda u, v: [r*cos(u), (R+r*sin(u))*cos(v), (R+r*sin(u))*sin(v)]
splot(f, [0, 2*pi], [0, 2*pi])
.. autofunction:: mpmath.splot
|