Skip to main content

Sympy Plotting Backends

PyPI version Install with conda Documentation Status Binder

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 the sympy.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 the PlotGrid 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:

  1. Better interactive experience (explored in the tutorial notebooks).
  2. 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:

  1. Read the documentation and follow the tutorials.
  2. Click the following button to run the tutorials with Binder. 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:

  1. label keyword argument has been removed.
  2. nb_of_points_* keyword arguments have been replaced by n or n1, n2.
  3. 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 use BokehBackend, 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 with BokehBackend:
    • 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.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sympy-plot-backends 0.14.0
File Size Uploaded Provenance Actions
sympy_plot_backends-0.14.0.tar.gz 103.3 kB Without provenance Details for sympy_plot_backends-0.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sympy-plot-backends 0.14.0
File Interpreter ABI Platform Actions
sympy_plot_backends-0.14.0-py3-none-any.whl Python 3 none any Details for sympy_plot_backends-0.14.0-py3-none-any.whl

Total release size: 215.5 kB

Release files / sympy_plot_backends-0.14.0.tar.gz

Download URL sympy_plot_backends-0.14.0.tar.gz
Size 103.3 kB
Tags Source
SHA-256 checksum
How to use checksums
04c3783556bdf5a35d46d2d56f970e6738883b9a2ef83bfff061946625334414
BLAKE2b-256 checksum
How to use checksums
20f65d0b35af63ef3a54a6be906e26ee6e1d697e8afb954ec6ef949fc0deaa6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / sympy_plot_backends-0.14.0-py3-none-any.whl

Download URL sympy_plot_backends-0.14.0-py3-none-any.whl
Size 112.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f28f95bd9a9f641f84dac61970c2795d5b7c1eafdb9650858d8d990efb0ef890
BLAKE2b-256 checksum
How to use checksums
a70c76479befa807dc9d940c3f65f3fcc589ad65338488d86309bb0fad33acf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Security for sympy-plot-backends 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.14.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page