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

Warning: this project is at an early stage.

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
  • Two renderers available: widget, which generates plots as Jupyter widgets, and jsdom, which generates SVG or HTML outputs
  • Pandas and polars DataFrame and Series objects are serialized using Arrow IPC format for improved speed and better data type conversions
  • 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
  • Works with Jupyter notebooks and Quarto HTML documents. Plots without legends are also supported in PDF and docx outputs with the jsdom renderer.

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.3.5.tar.gz (291.1 kB view details)

Uploaded Source

Built Distribution

pyobsplot-0.3.5-py3-none-any.whl (293.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyobsplot-0.3.5.tar.gz
  • Upload date:
  • Size: 291.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.6 Linux/5.19.0-41-generic

File hashes

Hashes for pyobsplot-0.3.5.tar.gz
Algorithm Hash digest
SHA256 d2bafdfc971518c3d4d5b5fa917a505dd2946238ef8e4dc130302f41608d4c90
MD5 bac984409fa4a76895274a555a97183b
BLAKE2b-256 e2765aabfddf8191cb2457cb74f3e7f7a733db2ca7710fa471a1ddbeb7d0a7c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyobsplot-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 293.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.6 Linux/5.19.0-41-generic

File hashes

Hashes for pyobsplot-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db699dcd852b5dd0ad40c1a31e12d4a4e284f87bf1f7b52b7074f97e30994f89
MD5 1732013f91075f371b47082ec38b16e8
BLAKE2b-256 69abb74ee1c2a4b32e56a6992f7db50075c072cfa0452ec69fa025541ae7ed64

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