Backends for plotting with SymPy
Project description
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.
plot_vector
function to quickly visualize 2D/3D vector fields with quivers or streamlines.plot_complex
function 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.plot_polar
function.plot_geometry
to quickly visualize entities from thesympy.geometry
module.iplot
function to create parametric-interactive plots using widgets (sliders, buttons, etc.).get_plot_data
function to easily extract the numerical data from symbolic expressions, which can later be used to create custom plots with our plotting library of choice.plotgrid
function, which replaces thePlotGrid
class: 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:
label
keyword argument has been removed.nb_of_points_*
keyword arguments have been replaced byn
orn1, n2
.ImplicitSeries
now 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
iplot
function 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
plotgrid
with different types of plots (PlotlyBackend, BokehBackend
, etc.). - While using the
iplot
function 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sympy_plot_backends-0.13.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7b96d335c6ad96342dae343254e942ecbd078ad12dc7e413eef4f1b438abbe |
|
MD5 | f70e23463ac8981010a77457c3b94c33 |
|
BLAKE2b-256 | 6a70ca1668f5854be62dfa1eeeda97dab9f77d88d252d40829521e1fbaa913cc |
Hashes for sympy_plot_backends-0.13.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3811622a6bbd8ff672e217f5909bb273b0952f7b0753784bba08c3ce6cf25496 |
|
MD5 | bd78cfdf185e6ba3039325cca61f2518 |
|
BLAKE2b-256 | 8a9471a85c4111693678e9d671049d2018dbc44c63fdbf5edf3ed74f463050a2 |