Repository navigation
Web figures: theme-neutral Plotly JSON for the docs sites - #85
Merged
Merged
Conversation
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.
Adds a file format for interactive figures on the max-models docs sites, and the writer for it, so a figure is saved once and embedded on any page without plotly.js in the file.
maxplotlib.webweb_figure(fig, title=, alt=, aspect=, white_plot=)turns any Plotly figure (or its JSON as a dict) into the format;write_web_figure(fig, path, ...)writes it.data,layout,frames) with no look of its own: no template, no fixed size, and transparent backgrounds. The axes getautomarginso the tick labels fit at any size.C0–C9, Plotly's colorway, Okabe–Ito) getstrace.meta.color_slot. The page can then give it the theme's colour in that position. Traces without a colour followlayout.colorway, black traces take the text colour, and other explicit colours and colormaps stay.layout.meta.web:version,title,alt,aspect,white_plot(on by default for figures converted from Matplotlib).Canvas
canvas.to_json(title=, alt=, white_plot=)returns the web figure;canvas.savefig("x.plotly.json", backend="plotly")writes it. The aspect ratio comes from the canvas size.Docs
PlotlyFigure, and the format's specification. The theme reads the palette slots and hints from PlotlyFigure: a data palette and web figure hints starlight-theme#53 on. Before that, it already loads plotly.js on demand and recolours text, grid and backgrounds.Checks