Skip to content

ggrust

The grammar of graphics, with a Rust engine and a lets-plot API.

pythonrustgrammar of graphics interactivearrowpolars

Get started Gallery

ggrust is a plotting library for Python. You describe a plot with ggplot, aes, geom_*, scale_* and theme, joined with +, exactly as in lets-plot. Rust computes the stats, scales and layout and draws the picture. Hover the plot above for tooltips: every plot on this site is a live ggrust plot.

Install

pip install ggrust
uv add ggrust
poetry add ggrust

Wheels are published for Linux, macOS and Windows, for Python 3.11 and newer. Nothing else is needed: no Java, no browser, no JavaScript build.

Why ggrust

  • The lets-plot API


    from ggrust import * instead of from lets_plot import *. Specs compose with + and as_dict() gives the same layout, so most code ports as an import swap.

    Migrating from lets-plot

  • Fast, in Rust


    Stats, scales, layout and rendering run in Rust. Data crosses from Python once, as Arrow: polars, pandas, pyarrow and dicts of numpy arrays all work.

    Layers

  • Interactive by default


    Notebook and HTML output has tooltips, and zoom and pan with ggtb(). Dense point layers are drawn on a canvas, so a hundred thousand points stay smooth.

    Interactivity

  • SVG, PNG, PDF, HTML


    One embedded font makes text measurement, and every PNG, identical on every machine. Export without a browser or any system library.

    Export

A taste

import polars as pl
from ggrust import *

DATA = "https://raw.githubusercontent.com/datavil/ggrust/main/docs/data/"
cities = pl.read_csv(DATA + "cities.csv")

plot = (
    ggplot(cities, aes("month", "temperature", color="city"))
    + geom_ribbon(aes(ymin="low", ymax="high", fill="city"), alpha=0.12, color="rgba(0,0,0,0)")
    + geom_line(size=1)
    + geom_point(size=2.5)
    + scale_x_continuous(
        breaks=[1, 3, 5, 7, 9, 11], labels=["Jan", "Mar", "May", "Jul", "Sep", "Nov"]
    )
    + labs(x="", y="Temperature (°C)", color="", fill="")
    + theme_minimal()
    + ggsize(480, 320)
)
plot

ggrust was built for cellestial, a single-cell plotting library, after lets-plot's Kotlin notebook support ended. It is a general plotting library: the gallery uses everyday data.