Skip to main content

Observable Plot in Jupyter notebooks and Quarto documents

Project description

pyobsplot

PyPI npm Tests Documentation Open In Colab

pyobsplot allows to use Observable Plot to create charts in Jupyter notebooks, VSCode notebooks, Google Colab and Quarto documents. Plots are created from Python code with a syntax as close as possible to the JavaScript one.

It allows to do things like :

import polars as pl
from pyobsplot import Plot

penguins = pl.read_csv("https://github.com/juba/pyobsplot/raw/main/doc/data/penguins.csv")

Plot.plot({
    "grid": True,
    "color": {"legend": True},
    "marks": [
        Plot.dot(
            penguins,
            {"x": "flipper_length_mm", "y": "body_mass_g", "fill": "species"}
        ),
        Plot.density(
            penguins,
            {"x": "flipper_length_mm", "y": "body_mass_g", "stroke": "species"}
        )
    ]
})

Sample plot screenshot

Installation and usage

pyobsplot can be installed with pip:

pip install pyobsplot

For usage instructions, see the documentation website:

If you just want to try this package without installing it on your computer, you can open an introduction notebook in Google Colab:

Features and limitations

Features:

  • Syntax as close as possible to the JavaScript one
  • Plots can be generated as Jupyter widgets, or as SVG, HTML or PNG outputs (via typst)
  • Plots can be saved to Widget HTML, static HTML, SVG, PNG or PDF files
  • Pandas and polars DataFrame and Series objects are serialized using Arrow IPC format for improved speed and better data type conversions
  • Works with Jupyter notebooks and Quarto documents
  • Works offline, no iframe or dependency to Observable runtime
  • Caching mechanism of data objects if they are used several times in the same plot
  • Custom JavaScript code can be passed as strings with the js method
  • Python date and datetime objects are automatically converted to JavaScript Date objects

Limitations:

Credits

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

pyobsplot-0.5.0.tar.gz (450.2 kB view details)

Uploaded Source

Built Distribution

pyobsplot-0.5.0-py3-none-any.whl (312.9 kB view details)

Uploaded Python 3

File details

Details for the file pyobsplot-0.5.0.tar.gz.

File metadata

  • Download URL: pyobsplot-0.5.0.tar.gz
  • Upload date:
  • Size: 450.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pyobsplot-0.5.0.tar.gz
Algorithm Hash digest
SHA256 beb7fa191e854a136e01766fa393f2939b4bfa372ed1ebd0d1a5e9b1ba88dc7f
MD5 1995286a31e44f9d71bbe2135244fcf5
BLAKE2b-256 25af55b61ac69dc42a6f69ac2fb92b8b5f24e9286e33ddf958347ae5cd93b0d2

See more details on using hashes here.

File details

Details for the file pyobsplot-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pyobsplot-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 312.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pyobsplot-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58ecbfad3aaec572b3d8bf7c68a15e3a6e9f547686c09793c404c87e3ad9dc6
MD5 d1f9101fdd10b91ec6eb3952f1abff3f
BLAKE2b-256 5883bb46a13f348827bb7bdcdf1108f079cd81150b2db5ce7b82fdfd8de63d69

See more details on using hashes here.

Supported by

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