Skip to content

PlotlyFigure: a data palette and web figure hints - #53

Merged
max-models merged 1 commit into
develfrom
web-figure-palette
Nov 7, 2026
Merged

max-models merged 1 commit into
develfrom
web-figure-palette

Conversation

@max-models

@max-models max-models commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

PlotlyFigure now draws a figure's data in the site's colours as well as its text, grid and backgrounds, and reads the hints of web figures written by maxplotlib.web (max-models/maxplotlib#85).

  • Data palette: --mm-data-1 … --mm-data-8 in styles/theme.css, after Okabe–Ito (colour-blind safe), lighter in dark mode. The palette is every figure's colorway. A trace with meta.color_slot (a colour from a default cycle) takes the palette colour of that slot on its line, markers and fill, keeping the fill's alpha. Black traces take the text colour, so reference curves stay visible in dark mode. The colours switch with the theme toggle through Plotly.react, with uirevision so zoom and pan are kept.
  • Hints (layout.meta.web): aspect sets the aspect ratio of the box, alt/title its aria-label. white_plot keeps a white plot area and the figure's own colours. New optional props alt and aspect set these before the figure loads.
  • The logic lives in lib/plotly-theme.ts as pure functions with vitest tests. The README has a new section, "Plotly figures", covering MDX use, the web figure format and the palette.

Gallery and notebook figures also get the palette as their colorway.

Checked in the example site (dev server, Chromium) with a maxplotlib canvas: slotted traces take the light and dark palette colours, a black line takes the text colour, and a white_plot figure keeps its colours on white. npm run test:js: 82 passed.

@max-models
max-models merged commit 2be2a48 into devel Nov 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant