Repository navigation
PlotlyFigure: a data palette and web figure hints - #53
Merged
Merged
Conversation
This was referenced Nov 7, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PlotlyFigurenow 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 bymaxplotlib.web(max-models/maxplotlib#85).--mm-data-1…--mm-data-8instyles/theme.css, after Okabe–Ito (colour-blind safe), lighter in dark mode. The palette is every figure's colorway. A trace withmeta.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 throughPlotly.react, withuirevisionso zoom and pan are kept.layout.meta.web):aspectsets the aspect ratio of the box,alt/titleitsaria-label.white_plotkeeps a white plot area and the figure's own colours. New optional propsaltandaspectset these before the figure loads.lib/plotly-theme.tsas 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_plotfigure keeps its colours on white.npm run test:js: 82 passed.