Skip to content

feat: add facet_titles kwarg to strip dim= prefix#77

Open
FBumann wants to merge 1 commit intomainfrom
feat/facet-titles
Open

feat: add facet_titles kwarg to strip dim= prefix#77
FBumann wants to merge 1 commit intomainfrom
feat/facet-titles

Conversation

@FBumann
Copy link
Copy Markdown
Owner

@FBumann FBumann commented May 7, 2026

Summary

  • New facet_titles keyword on every accessor/plotting method (xpx(da).line(facet_col=..., facet_titles="value")). Accepts:
    • "default" (default) — keep PX's "<dim>=<value>" subplot titles, no behavior change.
    • "value" — strip the <dim>= prefix, leaving just the value.
  • New public helper simplify_facet_titles(fig, mode) for figures built outside the accessor (e.g. raw PX, overlay, add_secondary_y outputs).
  • Shared Literal["value", "default"] alias FacetTitlesMode in xarray_plotly.common.

Defensive: only annotations whose text starts with a Python-identifier prefix followed by = are touched, so user-added annotations are preserved.

Test plan

  • pytest tests/ — 152 passed (7 new tests for the helper + kwarg).
  • mypy xarray_plotly tests — clean.
  • Verified default behavior unchanged on every plot method (line, bar, area, scatter, fast_bar, box, imshow, pie) for both DataArrayPlotlyAccessor and DatasetPlotlyAccessor.

🤖 Generated with Claude Code

Plotly Express renders faceted subplot titles as "<dim>=<value>"
(e.g. "country=Brazil"). The new `facet_titles` keyword on every
plotting/accessor method ("default" or "value") lets callers strip
the prefix without a separate post-processing step. Default is
"default" — no behavior change for existing users.

Also adds a public `simplify_facet_titles(fig, mode)` helper for use
on figures from any source (overlay/add_secondary_y outputs, raw
PX figures, etc.). Both share the same Literal type alias
`FacetTitlesMode` exported from `common`.

Only annotations whose text starts with a Python-identifier prefix
followed by `=` are touched, so user-added annotations are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@FBumann has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 29 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71046951-c60d-42b7-8bcb-89d2080b2aef

📥 Commits

Reviewing files that changed from the base of the PR and between c889e9a and 686e565.

📒 Files selected for processing (6)
  • tests/test_figures.py
  • xarray_plotly/__init__.py
  • xarray_plotly/accessor.py
  • xarray_plotly/common.py
  • xarray_plotly/figures.py
  • xarray_plotly/plotting.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/facet-titles

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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