Turn static matplotlib charts into interactive web visualizations, and export them to HTML files
Project description
plotjs: Turn static matplotlib charts into interactive web visualizations
plotjs is a Python package that transform matplotlib plots into interactive charts with minimum user inputs. It's very easy to use and highly extensible! It lets you:
- control tooltip labels and grouping
- add CSS
- add JavaScript
- and many more
[!IMPORTANT] Consider that the project is still unstable.
Installation
From PyPI (recommended):
pip install plotjs
Latest dev version:
pip install git+https://github.com/y-sunflower/plotjs.git
Quickstart
plotjs mainly provides a PlotJS class
import matplotlib.pyplot as plt
from plotjs import PlotJS, data
df = data.load_iris()
fig, ax = plt.subplots()
ax.scatter(
df["sepal_length"],
df["sepal_width"],
c=df["species"].astype("category").cat.codes,
s=180,
alpha=0.6,
ec="black",
)
(
PlotJS(fig)
.add_tooltip(labels=df["species"])
.save("iris-scatter.html")
)
Open iris-scatter.html in your browser to get hover tooltips and default highlight/fade behavior.
Why plotjs?
plotjs keeps your existing matplotlib workflow and adds interactivity on top of the SVG that matplotlib already knows how to generate. Instead of rebuilding the chart in another library, you keep the same Figure, export it to HTML, and control the browser-side behavior with CSS and JavaScript.
Learn more in the Q&A.
Features Overview
- Keep your existing matplotlib figure and export it as a standalone interactive HTML file
- Add hover tooltips from any iterable of labels
- Highlight related elements together with
groups=... - Restrict interactivity to specific element types with
on=... - Use direct hover or nearest-element hover with
hover_nearest=True - Add custom CSS with strings, dictionaries, or files
- Add custom JavaScript with strings or files, and optionally load D3.js
- Work with multiple matplotlib axes in the same figure
- Export either to disk with
save()or to an HTML string withas_html()
Documentation
- Getting started
- PlotJS API reference
- CSS guide
- JavaScript guide
- Embedding in Quarto, marimo, or websites
- Troubleshooting
- Developer architecture overview
Contribution
Looking to contribute? Check out the contributing guide. You can get an overview of how the project works here, and in the AGENTS.md file.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plotjs-0.0.12.tar.gz.
File metadata
- Download URL: plotjs-0.0.12.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c54c8b1d1597deeded3d6f2c1e52ab3e4cdb2eb74b1627ad905566fcceb7c5
|
|
| MD5 |
9534889a195349ad902b6d7d50f4c065
|
|
| BLAKE2b-256 |
56538fe52ad9f7daa88ff89ed019aac55f7105ff2bd3714d5f723f612deee309
|
Provenance
The following attestation bundles were made for plotjs-0.0.12.tar.gz:
Publisher:
pypi.yaml on y-sunflower/plotjs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plotjs-0.0.12.tar.gz -
Subject digest:
98c54c8b1d1597deeded3d6f2c1e52ab3e4cdb2eb74b1627ad905566fcceb7c5 - Sigstore transparency entry: 1188916348
- Sigstore integration time:
-
Permalink:
y-sunflower/plotjs@8de99a7401ff8d8d89b02dbd1fbf51095a39c73d -
Branch / Tag:
refs/tags/v0.0.12 - Owner: https://github.com/y-sunflower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@8de99a7401ff8d8d89b02dbd1fbf51095a39c73d -
Trigger Event:
push
-
Statement type:
File details
Details for the file plotjs-0.0.12-py3-none-any.whl.
File metadata
- Download URL: plotjs-0.0.12-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10bacee9fe196eff5112f82485ea1ad8117883d1b0f034ace9b0a49ac080b5ab
|
|
| MD5 |
bbc74606ff443aa0afd0f59b938d5d2c
|
|
| BLAKE2b-256 |
fe7214731320a7d7d962e212a53e0c6423f49b5ba6ff12765b2a67de1f3244e5
|
Provenance
The following attestation bundles were made for plotjs-0.0.12-py3-none-any.whl:
Publisher:
pypi.yaml on y-sunflower/plotjs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plotjs-0.0.12-py3-none-any.whl -
Subject digest:
10bacee9fe196eff5112f82485ea1ad8117883d1b0f034ace9b0a49ac080b5ab - Sigstore transparency entry: 1188916355
- Sigstore integration time:
-
Permalink:
y-sunflower/plotjs@8de99a7401ff8d8d89b02dbd1fbf51095a39c73d -
Branch / Tag:
refs/tags/v0.0.12 - Owner: https://github.com/y-sunflower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yaml@8de99a7401ff8d8d89b02dbd1fbf51095a39c73d -
Trigger Event:
push
-
Statement type: