This module contains a few plotting backends that can be used with SymPy and Numpy. A backend represents the plotting library: it provides the necessary functionalities to quickly and easily plot the most common types of symbolic expressions (line plots, surface plots, parametric plots, vector plots, complex plots, control system plots).
The following plotting libraries are supported: Matplolib, Plotly, Bokeh, K3D-Jupyter, Mayavi.
On top of the usual plotting functions exposed by SymPy (plot
,
plot_parametric
, plot3d
, etc.), this module offers the capabily to:
- use a different plotting library.
- visualize discontinuities on 2D line plots.
plot_vector
to quickly visualize 2D/3D vector fields with quivers or streamlines.plot_real_imag
,plot_complex
,plot_complex_list
,plot_complex_vector
to visualize complex functions.plot_geometry
to quickly visualize entities from thesympy.geometry
module.- capability to create parametric-interactive plots using widgets (sliders, buttons, etc.) with ipywidgets or Holoviz's Panel.
plotgrid
function, which replaces thePlotGrid
class: it allows to combine multiple plots into a grid-like layout. It works with Matplotlib, Bokeh and Plotly.plot_bode
,plot_nyquist
,plot_nichols
, etc. to visualize control systems.
Please, read the
following documentation page
to understand the differences between this module and sympy.plotting
.
If you feel like some feature could be implemented, open an issue or create a PR.
Read the documentation to explore the capabilities before the installation, which is filled with examples.
SymPy Plotting Backends can be installed with pip
or conda
. By default,
only basic plotting with Matplotlib will be installed:
pip install sympy_plot_backends
Or
conda install -c conda-forge sympy_plot_backends
To install the complete requirements in order to get interactive plots, bokeh, plotly, k3d, vtk, execute the following command:
pip install sympy_plot_backends[all]
Or:
conda install -c anaconda scipy notebook colorcet
conda install -c conda-forge adaptive
conda install -c conda-forge panel
conda install -c anaconda ipywidgets
conda install -c conda-forge ipympl
conda install -c bokeh ipywidgets_bokeh
conda install -c conda-forge k3d msgpack-python
conda install -c plotly plotly
conda install -c conda-forge vtk
Finally, if you are using zshell, the above pip
command is going to fail.
Use the following instead:
pip install "sympy_plot_backends[all]"
Some backend comes with a memory cost. Since they require external libraries and/or open a server-process in order to visualize the data, memory usage can quickly rise if we are showing many plots. Keep an eye on you system monitor and act accordingly (close the kernels, restart the browser, etc.).