g

gribouille

@preview

Create elegant graphics with the Grammar of Graphics.

v0.7.0
MIT

Package Information

Last Updated
Minimum Typst Version
0.15.0
Categories
visualization

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/gribouille:0.7.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/gribouille:0.7.0": *

Version History

0.7.00.15.0
780a662d4fe3...
0.6.00.14.0
6a18abbef392...
0.5.00.14.0
f7d2672d9223...
0.4.10.14.0
f65bae44ba1a...
0.3.00.14.0
9cb7e3c4cad6...
0.2.10.14.0
af3280159114...
0.1.10.14.2
5ae78453ccbd...
0.1.00.14.2
72d6e7fcf21b...

Gribouille

Create elegant graphics with the Grammar of Graphics for Typst.

Gribouille is French for "scribble".
The library implements Wilkinson's Grammar of Graphics in a declarative API for Typst documents, inspired by ggplot2 (R) and plotnine (Python).

Documentation: https://m.canouil.dev/gribouille.

Quick look

#import "@preview/gribouille:0.7.0": *

#let species-colours = (
  Adelie: rgb("#ff8c00"),
  Chinstrap: rgb("#008B8B"),
  Gentoo: rgb("#800080"),
)

#plot(
  data: penguins,
  mapping: aes(
    x: "flipper-len",
    y: "body-mass",
    colour: "species",
    fill: "species",
    shape: "species",
  ),
  layers: (
    geom-point(size: 2pt, alpha: 0.25, stroke: 0.5pt, colour: rgb("#ffffff")),
    geom-smooth(method: "lm", se: true, alpha: 0.2),
    geom-mark(method: "hull", expand: 5pt, alpha: 0.25),
    geom-errorbar(stat: stat-summary(fun: "mean-sd"), width: 5pt),
    geom-errorbarh(stat: stat-summary(fun: "mean-sd"), height: 5pt),
    geom-label(
      stat: stat-summary(fun: "mean"),
      mapping: aes(label: "species"),
      colour: rgb("#ffffff"),
      size: 8pt,
    ),
  ),
  scales: scales(
    x: scale-continuous(),
    y: scale-continuous(labels: format-comma()),
    colour: scale-discrete(
      limits: species-colours.keys(),
      palette: species-colours.values(),
    ),
    fill: scale-discrete(
      limits: species-colours.keys(),
      palette: species-colours.values(),
    ),
  ),
  labels: labels(
    title: typst("Penguins *Dataset*"),
    subtitle: typst({
      [Flipper length vs body mass by species: ]
      species-colours
        .pairs()
        .map(p => text(fill: p.at(1), weight: "bold")[#p.at(0)])
        .join(", ")
    }),
    caption: "Data from Palmer Archipelago (Antarctica) penguin dataset.",
    colour: "Species",
    fill: "Species",
    shape: "Species",
    x: "Flipper Length (mm)",
    y: "Body Mass (g)",
  ),
  theme: theme-minimal(),
  width: 12cm,
  height: 9cm,
)

AI assistants

The documentation ships a machine-readable copy for large language models at https://m.canouil.dev/gribouille/llms.txt.
Every page also has a .llms.md companion.

An installable skill teaches coding agents to author Gribouille plots against that reference.
Install it with the agent-neutral skills CLI:

npx skills add mcanouil/gribouille

The repository also doubles as a plugin marketplace:

/plugin marketplace add mcanouil/gribouille
/plugin install gribouille@gribouille

See the AI Assistants guide for details.