Add a new template parameter to ridgeplot()#389
Merged
Conversation
Allow users to specify a Plotly figure template (by name, as a go.layout.Template object, or as a dict) directly through the new `template` parameter. When no explicit `colorscale` is specified, the default colorscale is now also inferred from the specified template.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04f93a4d36
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 19 +1
Lines 657 674 +17
Branches 85 88 +3
=========================================
+ Hits 657 674 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #238
Summary
This PR adds a new
templateparameter toridgeplot(), allowing users to theme their plots with Plotly figure templates:"+"-merged names, e.g."plotly_white+ggplot2"), ago.layout.Templateobject, or a dictionary with a template's properties. Validation/coercion is delegated to Plotly's ownBaseTemplateValidator, so error messages match Plotly's.colorscaleis now inferred from the specified template (i.e., fromtemplate.layout.colorscale.sequential), unless the user explicitly sets a customcolorscale, which still takes precedence.templateis not specified (default), the behaviour is completely unchanged: the figure is rendered with Plotly's current default template (plotly.io.templates.default) and the default colorscale is inferred from it (the existing e2e artifacts remain byte-identical).Changes
src/ridgeplot/_types.py: newPlotlyTemplatetype aliassrc/ridgeplot/_template.py: new module withvalidate_coerce_template()src/ridgeplot/_color/colorscale.py:infer_default_colorscale()andvalidate_coerce_colorscale()now accept an optional resolvedtemplatesrc/ridgeplot/_figure_factory.py: plumb the newtemplateargument throughcreate_ridgeplot()and apply it to the figure's layoutsrc/ridgeplot/_ridgeplot.py: new publictemplateparameter (+ docstring)colorscale(100% diff coverage)Test plan
pytest tests/unit --doctest-modules src(251 passed)pytest tests/e2e/test_examples.py::test_json_regressions(artifacts unchanged)pyright(0 errors)pre-commithooks (incl. ruff format/lint)📚 Documentation preview 📚: https://ridgeplot--389.org.readthedocs.build/en/389/