• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Observable Plot in Jupyter notebooks and Quarto documents

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:

  • Plot interactions (tooltips, crosshair...) are not available with the jsdom renderer (#16).
  • Plots with legends don't work in Quarto in formats other than HTML. (#9)
  • Very limited integration with IDE (documentation and autocompletion) for Plot methods. (#13)

Credits

More Repositories

1

rmdformats

HTML output formats for RMarkdown documents
CSS
714
star
2

explor

Interfaces for Multivariate Analysis in R
R
192
star
3

robservable

Observable notebooks as R htmlwidgets
HTML
158
star
4

scatterD3

R scatter plot htmlwidget based on D3.js
JavaScript
158
star
5

color-theme-tangotango

An emacs color theme based on the tango palette colors
Emacs Lisp
149
star
6

shinyglide

Glide.js component for Shiny apps
R
91
star
7

questionr

R package to make surveys processing easier
R
82
star
8

obsplot

Observable Plot bindings for R
R
60
star
9

rainette

R implementation of the Reinert text clustering method
R
53
star
10

bookup-html

Bookup custom Quarto HTML format
SCSS
48
star
11

tidyverse

Introduction à R et au tidyverse
SCSS
45
star
12

uniquanti

Small JavaScript app to visualize basic statistics
JavaScript
42
star
13

rwos

R interface to Web of Science Web Services API
R
22
star
14

scatterD3_shiny_app

Minimal example shiny app for the scatterD3 package : https://github.com/juba/scatterD3
R
12
star
15

textile-mode

An emacs major mode for Textile markup language editing.
Emacs Lisp
6
star
16

khi2_slides

Présentation sur le test du Khi2
HTML
6
star
17

intro-r

(Obsolète) Introduction à R
PostScript
6
star
18

shiny_prenoms

Shiny app for french first names at birth dataset
R
6
star
19

texplor

Interactive Interfaces for Textual Analysis in R
R
5
star
20

timeline-generator

PDF timeline generator (Ruby, LaTeX, TikZ)
Ruby
5
star
21

presid2012-bureaux-lyon

Résultats du premier tour des présidentielles de 2012 dans les bureaux de vote de Lyon
R
2
star
22

rgrs

R package that provides functions for beginners and social sciences students or researchers (cross-tabulation, weighting, results export, and maps plotting).
R
2
star
23

presid2012-classif-communes

Classification des communes de France selon leurs votes au premier tour de l'élection présidentielle 2012
R
2
star
24

archive_doc_khi2

Archive d'un document d'introduction au test du Khi2
TeX
2
star
25

StableDiffusionNotebook

Stable diffusion custom notebook
Jupyter Notebook
1
star
26

advent-2023

Advent of code 2023
Python
1
star
27

umapscan

UMAP dimensionality reduction and DBSCAN clustering R helper package
R
1
star
28

rmarkdown_rlyon_2014

Slides de présentation de Rmarkdown à RLyon - 20/11/2014
CSS
1
star
29

org-seenthis

Interface between emacs' org-mode and seenthis.net
Emacs Lisp
1
star
30

js-exos

Questions-réponses en html/javascript
JavaScript
1
star