Gribouille 0.3.0:Typst 的图形语法
Gribouille 0.3.0: A Grammar of Graphics for Typst

原始链接: https://mickael.canouil.fr/posts/2026-06-15-gribouille-0-3/

Gribouille 0.3.0 在 Typst 的绘图控制和易用性方面带来了显著改进。最值得注意的更新是增强了 `guides()` 函数,现在无需进行复杂的主题调整,即可直接控制坐标轴刻度、标签和图例。 **主要更新包括:** * **改进的控制功能:** `guides()` 现在可以隐藏特定的坐标轴(如 `guides(x: none)`)或所有图例(如 `guides(default: none)`)。此功能同样适用于极坐标。 * **组合与主题:** `compose()` 现在支持 `theme` 参数,该参数可级联应用于所有面板。此外,`plot(..., defer: true)` 已被更简洁的 `defer(plot, ...)` 语法所取代。 * **几何图形与注释:** `geom-area()` 现在默认为堆叠排列,并针对不匹配的数据提供自动重采样。`annotate()` 增加了 `clip: false` 选项,允许标记延伸到面板边界之外。 * **优化:** 本次更新包括针对图例布局的各种错误修复、改进了二维分箱(2D bins)的统计功能,并通过对 Tinymist 友好的文档字符串增强了对 IDE 的支持。 此版本强调了管理绘图元素时更直观的 API,在保持主题简洁且易于维护的同时,更容易实现复杂的布局。

```Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Gribouille 0.3.0:Typst 的图形语法 (canouil.fr) 11 分 | mcanouil 发布于 2 小时前 | 隐藏 | 过往 | 收藏 | 讨论 | 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 加入 YC | 联系 搜索: ```
相关文章

原文

Another week, another Gribouille release. Gribouille 0.3.0 is narrower in scope than 0.2, but it brings some wanted controls. The headline is guide control: a single argument now hides axis ticks and legends without touching the theme. Alongside that, compose() gains a theme: parameter, defer() replaces plot(..., defer: true), geom-area() stacks by default, and annotate() can let marks overflow the panel.

Featured card for the Gribouille 0.3.0 release on a cream paper
background. On the left, the Gribouille wordmark sits above the tagline
"Create elegant graphics with the Grammar of Graphics for Typst.", a
small orange "v0.3.0 release" pill, and the URL
m.canouil.dev/gribouille. On the right, a slightly rotated bordered card
frames a scatter plot of Palmer Penguin body mass against flipper
length, with the three species shown as coloured point clouds.

  • Gribouille 0.3.0 on Typst Universe: #import "@preview/gribouille:0.3.0": *.
  • guides(x: none) / guides(y: none) hide tick marks and tick labels; the axis line, grid, and title stay. Remove the title separately with labs(x: none).
  • guides(default: none) hides every legend without its own override.
  • Under coord-radial, guides(theta: none) hides the full angular axis and guides(r: none) hides radial tick labels.
  • guides(none) replaces the removed guide-none(); guides(auto) restores the default.
  • compose() gains theme:, which styles the composition chrome and propagates into panels with no theme of their own.
  • Breaking change: plot(..., defer: true) is replaced by defer(plot, ...). Panels inside a compose() also no longer accept their own width/height.
  • geom-area() defaults to stat: "align" and position: "stack"; groups with mismatched x values are resampled automatically.
  • annotate() gains clip: (default true); clip: false lets a mark overflow the panel.

Every figure in this post is a real, freshly compiled plot.

Guide controls

The biggest visible change is a new layer of control over what guides draw.

Before 0.3.0, hiding an axis’s tick marks and labels meant reaching into theme() for the right element surface. Now, guides(x: none) does it directly. The axis line, the vertical grid lines, and the axis title all stay. To drop the title too, add labs(x: none) alongside it.

The same syntax now controls legends too. guides(none) hides a legend; guides(auto) restores the default. Both replace the removed guide-none().

When you want all legends gone at once, guides(default: none) sets the fallback for every aesthetic without its own override.

Radial guide controls

The same guide syntax extends to coord-radial. guides(theta: none) hides the full angular axis, the arc, minor ticks, and tick labels together. guides(r: none) hides only the radial tick labels, leaving the spokes and circles in place.

Compose gets a theme

Two changes landed in compose() together.

The first is a theme: parameter. Pass a theme and it styles the composition chrome: the shared title, the hoisted legend, and the panel tags. It also propagates into any panel that has no theme of its own, so you can set one theme once and let it cascade instead of repeating it across every panel.

The second is the defer() helper.

plot(..., defer: true) is removed. Replace plot(data: ..., ..., defer: true) with defer(plot, data: ..., ...). Panels inside a compose() also no longer accept their own width/height; the composition sizes each cell.

Area stacks by default

geom-area() now defaults to stat: "align" and position: "stack".

Before 0.3.0, stacking a multi-group area chart needed both arguments spelled out. Now they are the defaults. stat: "align" also handles groups that have different x values: it resamples each group onto a shared grid before stacking, so the x values do not need to match.

Annotations can overflow

annotate() gains a clip argument. The default is true, which preserves the existing behaviour: marks outside the panel are clipped. Set clip: false and the mark is drawn even if it sits past the axis limits.

This is useful for corner insets, labels anchored outside the data range, or decorations that belong in the margin. A paired fix ensures that an annotate(clip: false) placed outside the scale limits actually draws. Before 0.3.0, the out-of-range pre-pass silently dropped it.

Back to top

Reuse

Citation

BibTeX citation:

@misc{canouil2026,
  author = {CANOUIL, Mickaël},
  title = {Gribouille 0.3.0: {Finer} {Guide} {Control} and a {Themed}
    {Compose}},
  date = {2026-06-15},
  url = {https://mickael.canouil.fr/posts/2026-06-15-gribouille-0-3/},
  langid = {en-GB}
}

For attribution, please cite this work as:

CANOUIL, M. (2026-06-15). Gribouille 0.3.0: Finer Guide Control and a Themed Compose. Mickael.canouil.fr. https://mickael.canouil.fr/posts/2026-06-15-gribouille-0-3/
联系我们 contact @ memedata.com