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
  • 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.
  • Plots can be saved to SVG or HTML files

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.4.2.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

pyobsplot-0.4.2-py3-none-any.whl (303.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyobsplot-0.4.2.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for pyobsplot-0.4.2.tar.gz
Algorithm Hash digest
SHA256 7e35e7ea0511bdaa232d367e4da35c8eaaba02722b3769191a1f3d44c17fd971
MD5 8a247c473d3b46d0a70cff1b398e3a2e
BLAKE2b-256 c477c7abf017c88ac69152ce9c2e7c4451125666d19eee623ec5b10e26a458d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyobsplot-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 303.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.26.0

File hashes

Hashes for pyobsplot-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c31abcf5cd39959dc513c381a48d52303101c94f7556d01b0071fcaf94718f1b
MD5 8348eea4066d34f3d70e9cce258c0cb3
BLAKE2b-256 e2bd36a3c7fc483758e0726d95ee8c22bbd051cffdf4eb783f77ee86d3bd0188

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