Sympy Plotting Backends
This module contains a few plotting backends that can be used with SymPy as an alternative to the default Matplotlib backend. 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).
What's new in comparison to SymPy
On top of the usual plotting functions exposed by SymPy (plot, plot_parametric, plot3d, etc.), this module offers:
- capability to use a different backend.
- capability to correctly visualize discontinuities on 2D line plots.
- capability to correctlt visualize 2D line plots of piecewise functions.
vector_plotfunction to quickly visualize 2D/3D vector fields with quivers or streamlines.complex_plotfunction to quickly visualize 2D/3D complex functions. In particular, we can visualize the real and imaginary parts, the modulus and argument, 2D/3D domain coloring.polar_plotfunction.geometry_plotto quickly visualize entities from thesympy.geometrymodule.iplotfunction to create parametric-interactive plots using widgets (sliders, buttons, etc.).get_plot_datafunction to easily extract the numerical data from symbolic expressions, which can later be used to create custom plots with our plotting library of choice.plotgridfunction, which replaces thePlotGridclass: it allows to combine multiple plots into a grid-like layout. It works with Matplotlib, Bokeh and Plotly.
Backends
The 2 most important reasons for using a different backend are:
- Better interactive experience (explored in the tutorial notebooks).
- To use the plotting library we are most comfortable with. The backend can be used as a starting point to plot symbolic expressions; then, we could use the figure object to add numerical (or experimental) results using the commands associated to the specific plotting library.
The following plotting libraries are supported: Matplolib, Plotly, Bokeh, K3D-Jupyter
Explore the Capabilities
To explore the capabilities before the installation, you can:
- Read the documentation and follow the tutorials.
- Click the following button to run the tutorials with Binder.
Installation
The repository is avaliable on PyPi:
pip install sympy_plot_backends
And also on Conda:
conda install -c davide_sd sympy_plot_backends
Warnings
While this module is based on sympy.plotting, there are some differences (structural and usability) that make them incompatible. Interchanging between these two modules might lead to some errors! I suggest to use this module instead of sympy.plotting. On the usability side, the main differences are:
labelkeyword argument has been removed.nb_of_points_*keyword arguments have been replaced bynorn1, n2.ImplicitSeriesnow uses mesh grid algorithm and contour plots by default. It is going to automatically switch to an adaptive algorithm if Boolean expressions are found.
Currently, this module must be considered in beta phase. If you find any bug, please open an issue. If you feel like some feature could be implemented, open an issue or create a PR.
Finally, 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.).
Known Bugs
To implement this module, a great effort went into the integration of several libraries and maintaining a consistent user experience with the different backends.
However, there are a few known bugs inherited from dependency-libraries that we should be aware of:
- The
iplotfunction uses holovis'z panel. However, this introduces a bug: once we decide to useBokehBackend, we can't go back to other backends (the plots won't be visible in the output cell). The only way to fix this problem is to close Jupyter server and start again. - The aforementioned bug also manifests itself while using
plotgridwith different types of plots (PlotlyBackend, BokehBackend, etc.). - While using the
iplotfunction withBokehBackend:- the user-defined theme won't be applied.
- rendering of gradient lines is slow.
- color bars might not update their ranges.
- Plotly:
- with 2D domain coloring, the vertical axis is reversed, with negative values on the top and positive values on the bottom.
- with 3D complex plots: when we hover a point, the tooltip will display wrong information for the argument and the phase. Hopefully this bug will be fixed upstream.
Metadata
Release files for sympy-plot-backends 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sympy_plot_backends-0.13.0.tar.gz | 99.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sympy_plot_backends-0.13.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 206.4 kB
Release files / sympy_plot_backends-0.13.0.tar.gz
| Download URL | sympy_plot_backends-0.13.0.tar.gz |
|---|---|
| Size | 99.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d3f37e3a2fe08de516e6cdab502d5a72eac1c1e6bf4599e91dfb069cccd2a5b
|
|
BLAKE2b-256 checksum How to use checksums |
aa8800e898ed3a635d9933a5496fc966278371d96002f3a8a7eff5b6d57f8a0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|
Release files / sympy_plot_backends-0.13.0-py3-none-any.whl
| Download URL | sympy_plot_backends-0.13.0-py3-none-any.whl |
|---|---|
| Size | 107.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
161168dbcf3635e03f217dc4626024bf2217ad43b10114b129ef465247efc716
|
|
BLAKE2b-256 checksum How to use checksums |
61e229370defd5f88b865e599d1f9a5e1df4b14bf09e35565cc5782bc76f8a31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|