Skip to main content

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 logo

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.

Online demo



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 with as_html()

Documentation


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plotjs-0.0.11.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plotjs-0.0.11-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

Details for the file plotjs-0.0.11.tar.gz.

File metadata

  • Download URL: plotjs-0.0.11.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for plotjs-0.0.11.tar.gz
Algorithm Hash digest
SHA256 a58d60a7af90225a952741a853a35f895df38b55f8027f5dd3a22b7c72f7016f
MD5 d42cf572603d355c90b4cf62aa6e38a1
BLAKE2b-256 d9bcc4b160cb4eaf30e7784e67852a4d6685d39d504a9c0a5346e3b2ce8473eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for plotjs-0.0.11.tar.gz:

Publisher: pypi.yaml on y-sunflower/plotjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file plotjs-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: plotjs-0.0.11-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

Hashes for plotjs-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 00b9520e07771d897ff8a29e2ee6ad0052a540ae953357c0be6dda2276921b16
MD5 948aa485ddf66c1ac6dbdbbadf0a9c42
BLAKE2b-256 f9eafe5b7e7abcf6a0f4e9bd21192eff0cb89521c03561e68bba86b7d20c430f

See more details on using hashes here.

Provenance

The following attestation bundles were made for plotjs-0.0.11-py3-none-any.whl:

Publisher: pypi.yaml on y-sunflower/plotjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page