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.
  • vector_plot function to quickly visualize 2D/3D vector fields with quivers or streamlines.
  • complex_plot 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.
  • polar_plot function.
  • geometry_plot 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.13.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.13.0
File Size Uploaded
sympy_plot_backends-0.13.0.tar.gz 99.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sympy-plot-backends 0.13.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

4.2.0

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.4.5

2 release files

3.4.4

2 release files

3.4.3

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.14.0

2 release files

0.13.2

2 release files

0.13.1

2 release files

This release

0.13.0 This release

2 release files

0.12.9

2 release files

0.12.8

2 release files

0.12.7

2 release files

0.12.6

2 release files

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