Plotting capabilities - sympy/sympy GitHub Wiki

All this is about the new plotting module and mostly covers the matplotlib backend.

Many examples of the plotting module capabilities are given in the docstrings and the IPython notebooks that are part of the module. However, there are many other types of plots that can be implemented and those are not listed anywhere. Hence this page on which the capabilities of other software packages will be compared to the current plotting module.

All the syntax examples will be from the highest level convenience functions. No BaseSeries subclasses will be visible. The Plot class will not be called directly.

The most explicit form of the arguments is given for the API examples (eg. plot(expr, (var, from, to)) instead of plot(expr) which finds the independent variable and uses a default range).

Remark about the Plot class: The low-level way to create a plot is to create instances of BaseSeries and append them to a Plot instance. However, for convenience, Plot also supports creating these BaseSeries instances itself for a small subset of all BaseSeries subclasses. Check the factory class Series for details.

Remark about the examples from other software packages: Their APIs will differ.

Types of Plots

TODO: finish the table

Type API In Sympy Example Image Elsewhere
2D line plot of an expression plot(expr, (var, from, to)) Mathematica's Plot
2D parametric line plot plot(expr_x, expr_y, (param, from, to)) Mathematica's ParamatricPlot
3D parametric line plot plot(expr_x, expr_y, expr_z, (param, from, to)) Mathematica's ParametricPlot3D
3D surface plot of an expression plot(expr, (var_x, from_x, to_x), (var_y, from_y, to_y)) Mathematica's Plot3D
3D parametric surface plot plot(expr_x, expr_y, expr_z, (param1, from1, to1), (param2, from2, to2)) Mathematica's ParametricPlot3D
2D contour plot yes
3D contour plot needs better 3D backend
2D Density plot easy to add
3D Density plot needs better 3D backend
2D vector field plot easy to add
3D vector field plot easy to add
2D stream lines plot not too hard to add using scipy integrators
3D stream lines plot not too hard to add using scipy integrators
2D stream density plot ?
3D stream density plot ?, needs better 3D backend
Implicit 2D equations maybe a GSoC project for an efficient version (working on only a subset of all sympy expressions), not too hard to add inefficient version using scipy optimisation routines and/or sampling
Implicit 2D inequalities maybe a GSoC project for an efficient version, not too hard to add inefficient version using sampling
Implicit 3D equations not too hard to add inefficient version using scipy optimisation routines and/or sampling
Implicit 3D inequalities not too hard to add inefficient version using sampling, need better 3D backend
Maps of the complex plane easy to add
2D linear maps (matrix multiplications) easy to add
Integral curves just an alias for stream plots
Geometry entities ?, https://github.com/sympy/sympy/issues/14048
Plots over -oo, +oo not implemented Maple's implementation

Remark about "needs better 3D backend": Matplotlib does not work well with volumes (as opposed to surfaces). The alternative is Mayavi.

Options

TODO

Aesthetics

TODO

Plotting multiple graphs

TODO

Discontinuity/Asymptote detection

There is none. Compare to what Maple has.

Adaptive resolution

At the moment the number of samples is fixed (it can be changed by the user), which causes problems with oscillating functions.