GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - juba/pyobsplot: Observable Plot in Python

BranchesTags
Open more actions menu

Latest commit

 

History

764 Commits
764 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
doc
doc
 
 
examples
examples
 
 
packages/pyobsplot-js
packages/pyobsplot-js
 
 
src
src
 
 
tests
tests
 
 
utils
utils
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.prettierrc.json
.prettierrc.json
 
 
.python-version
.python-version
 
 
LICENSE
LICENSE
 
 
NEWS.md
NEWS.md
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

pyobsplot

PyPI npm Tests Documentation Open In Colab

pyobsplot allows to use Observable Plot to create charts in Jupyter or Marimo notebooks 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 uv or pip:

# uv
uv add pyobsplot[typst]
# pip
pip install pyobsplot[typst]

To use pyobsplot in JupyterLite or marimo you must install it without the typst dependency, which is not yet compatible with pyodide:

pip install pyobsplot

For usage instructions, see the documentation website:

  • See getting started for a quick usage overview.
  • See usage for more detailed usage instructions.

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

Colab badge

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, JupyterLite and Marimo notebooks as well as in 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:

  • Plot interactions (tooltips, crosshair...) are only available with the "widget" format (#16).
  • Very limited integration with IDE (documentation and autocompletion) for Plot methods. (#13)

Credits

  • Observable Plot, developed by Mike Bostock and Philippe Rivière among others.
  • The widget is developed thanks to the anywidget framework.
  • typst is used to convert HTML figures to PNG, SVG or PDF.
  • Some code from the jsdom renderer has been adapted from altair_saver.
  • The documentation website is generated by Quarto.

About

Observable Plot in Python

juba.github.io/pyobsplot/

Topics

anywidgetjupyterjupyter-widgetobservable-plotpythonquarto

Resources

Readme
MIT license
Activity

Stars

327 stars

Watchers

7 watching

Forks

11 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.