HTML5 backends for Matplotlib compatible with Pyodide
Project description
matplotlib-pyodide
HTML5 backends for Matplotlib compatible with Pyodide
This package includes two matplotlib backends,
- the
wasm_backend
which from allows rendering the Agg buffer as static images into an HTML canvas - an interactive HTML5 canvas backend
html5_canvas_backend
described in this blog post
Installation
This package will be installed as a dependency when you load matplotlib
in Pyodide.
Usage
To change the backend in matplotlib,
- for the wasm backend,
import matplotlib matplotlib.use("module://matplotlib_pyodide.wasm_backend")
- for the interactive HTML5 backend;
import matplotlib matplotlib.use("module://matplotlib_pyodide.html5_canvas_backend")
By default, matplotlib figures will be rendered inside a div that's appended to the end of document.body
.
You can override this behavior by setting document.pyodideMplTarget
to an HTML element. If you had an HTML
element with id "target", you could configure the backend to render visualizations inside it with this code:
document.pyodideMplTarget = document.getElementById('target')
For more information see the matplotlib documentation.
License
pyodide-cli uses the Mozilla Public License Version 2.0.
Project details
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 matplotlib_pyodide-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4079865801941c02f2d09eab7740762f02c272889cac906c16c67b1531eb3271 |
|
MD5 | 40a47ad95e0fbcedf5eb20a72b31f887 |
|
BLAKE2b-256 | d9b1c10dd6f133628343a2fe74a74d60c03e7c0a87724736be40e82c0247b8ce |