anytrellis¶
Trellis plots for Jupyter and marimo notebooks, drawn on the GPU. A trellis (also called small multiples, or facets) draws the same plot once for each group of a table, on the same scales, so you compare the groups at a glance. anytrellis draws every panel in one canvas, so a grid of hundreds of panels and millions of marks stays smooth to zoom.
The plots on these pages are live: hover over a point, click a plot and scroll to zoom, and drag to pan. Panels that share a scale zoom together.
from anytrellis import Trellis
from anytrellis.datasets import load
gapminder = load("gapminder")
plot = Trellis(gapminder, wrap="year", cols=4, title="Fertility and life expectancy")
plot.points(x="fertility", y="life_expect", color="region", tooltip=["country", "pop"])
plot
What it does¶
- Panels from your columns: a wrap of one column's levels (
wrap=), or a grid that crosses two (row=,col=) and keeps empty cells so rows and columns line up (tutorial, how to). - Scales you can compare: shared by every panel by default, or per row, per column or free; linear or log (tutorial, how to).
- Layers: lines, points, bars, areas, bands, rects, text and reference rules, and summaries computed per panel: histograms, box plots, densities and smooth fits (how to, distributions).
- Interaction: zoom and pan linked across panels, box zoom, fit y to the data in view, one panel at a time, full screen (mouse and keys).
- Selection that reaches Python: brush marks or click a legend entry, and
plot.selected()gives the rows; plots linked withlink()share one selection (tutorial, how to). - Any table: Polars, pandas, PyArrow or a dict of columns (how to).
- Pages that open anywhere:
save_htmlwrites the plot with its data into one HTML file that opens without Python (how to).
Where to start¶
- New to anytrellis? Start with Your first trellis plot: ten minutes, in a notebook.
- Looking for a kind of plot? The gallery shows each one, linked to the guide that makes it.
- Know ggplot2, seaborn or Altair? See how their facets translate: ggplot2 and seaborn, Altair and lattice.
- Looking up an argument? The reference lists every method.
Install¶
pip install anytrellis
anytrellis needs Python 3.12 or newer, and runs in JupyterLab, Jupyter Notebook, VS Code and marimo. See Install anytrellis.
The bundled datasets are credited in anytrellis.datasets; the gapminder data is based on free material from GAPMINDER.ORG, CC-BY LICENSE.