Home

Python Theme Target

Overview

Python kernels translate Stencila plot-* tokens into matplotlib rcParams. Lengths are converted to points, and fonts are resolved before being sent to the kernel.

This translation happens whenever Stencila executes Python code that produces plots, for example during a render:

stencila render report.ipynb report.html

Theme Transfer

  • Only plot-* tokens are sent to Python kernels (see lib.rs).

  • Lengths are converted to points, then mapped into matplotlib units (inches for figure size, points for text).

  • The Python theme implementation lives in theme.py.

Key Mappings

TokensMatplotlib rcParams
--plot-backgroundfigure.facecolor, savefig.facecolor
--plot-panelaxes.facecolor
--plot-panel-borderaxes.spines.* (false = left/bottom only)
--plot-axis-line-coloraxes.edgecolor
--plot-axis-line-widthaxes.linewidth
--plot-axis-title-coloraxes.labelcolor
--plot-axis-title-sizeaxes.labelsize
--plot-axis-title-weightaxes.labelweight
--plot-title-sizeaxes.titlesize
--plot-text-colortext.color, axes.titlecolor
--plot-font-familyfont.family
--plot-font-sizefont.size
--plot-width, --plot-heightfigure.figsize (pt to in)
--plot-dpifigure.dpi, savefig.dpi
--plot-padding-*figure.constrained_layout.h_pad / w_pad (max of top/bottom, left/right)
--plot-grid-colorgrid.color
--plot-grid-x-width, --plot-grid-y-width, --plot-grid-widthaxes.grid, grid.linewidth, axes.grid.axis
--plot-line-widthlines.linewidth
--plot-point-sizelines.markersize
--plot-point-opacityaxes.prop_cycle alpha + markers.fillstyle
--plot-color-1 ... --plot-color-12axes.prop_cycle colors
--plot-shape-1 ... --plot-shape-8axes.prop_cycle markers
--plot-line-type-1 ... --plot-line-type-6axes.prop_cycle linestyles
--plot-ramp-start, --plot-ramp-endimage.cmap (generated gradient)

Notes and Gaps

  • --plot-subtitle-size is not currently mapped in matplotlib.

  • If --plot-theme: none is set, kernels skip theming.

  • The authoritative mapping lives in theme.py.

© 2026 Stencila