feat: add facet_titles kwarg to strip dim= prefix#77
Conversation
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>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
facet_titleskeyword 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.simplify_facet_titles(fig, mode)for figures built outside the accessor (e.g. raw PX,overlay,add_secondary_youtputs).Literal["value", "default"]aliasFacetTitlesModeinxarray_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.DataArrayPlotlyAccessorandDatasetPlotlyAccessor.🤖 Generated with Claude Code