Skip to content

Add a new template parameter to ridgeplot()#389

Merged
tpvasconcelos merged 6 commits into
mainfrom
template-param
Jul 25, 2026
Merged

Add a new template parameter to ridgeplot()#389
tpvasconcelos merged 6 commits into
mainfrom
template-param

Conversation

@tpvasconcelos

@tpvasconcelos tpvasconcelos commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Closes #238

Summary

This PR adds a new template parameter to ridgeplot(), allowing users to theme their plots with Plotly figure templates:

fig = ridgeplot(samples=..., template="plotly_dark")
  • The parameter accepts the same representations as Plotly Express: the name of a registered template (including "+"-merged names, e.g. "plotly_white+ggplot2"), a go.layout.Template object, or a dictionary with a template's properties. Validation/coercion is delegated to Plotly's own BaseTemplateValidator, so error messages match Plotly's.
  • Consistent with the existing behaviour for the default template, the default colorscale is now inferred from the specified template (i.e., from template.layout.colorscale.sequential), unless the user explicitly sets a custom colorscale, which still takes precedence.
  • When template is 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: new PlotlyTemplate type alias
  • src/ridgeplot/_template.py: new module with validate_coerce_template()
  • src/ridgeplot/_color/colorscale.py: infer_default_colorscale() and validate_coerce_colorscale() now accept an optional resolved template
  • src/ridgeplot/_figure_factory.py: plumb the new template argument through create_ridgeplot() and apply it to the figure's layout
  • src/ridgeplot/_ridgeplot.py: new public template parameter (+ docstring)
  • New unit tests covering all accepted representations, error cases, and the interaction with 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-commit hooks (incl. ruff format/lint)
  • Sphinx docs build with no new warnings (cross-references to Plotly's API docs resolve correctly)

📚 Documentation preview 📚: https://ridgeplot--389.org.readthedocs.build/en/389/

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.
@github-actions

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/ridgeplot/_ridgeplot.py
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (658306c) to head (5bdfdab).

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     
Flag Coverage Δ
combined-src 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tpvasconcelos
tpvasconcelos merged commit 14e872d into main Jul 25, 2026
19 of 20 checks passed
@tpvasconcelos
tpvasconcelos deleted the template-param branch July 25, 2026 03:56
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.

Allow users to pass a template argument

1 participant