Add polar-aware rlabel and thetalabel support#714
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Isn't this already implemented? I have some time tomorrow to look at this but then will be mia for a while (cc @beckermr) |
|
Not really, as far as I’m aware. |
|
Never seen a Taylor diagram. That looks pretty handy for my work. Will review this today. |
for more information, see https://pre-commit.ci
|
This is moving in the right direction overall, and I like the thetalabel/rlabel API since it matches the existing polar theta/r vocabulary much better than Cartesian x/y labels. My main concern is that this PR currently also includes the earlier xlabel/ylabel support for PolarAxes.format() from #713, including the figure.py dispatch change and the regression test for ax.format(xlabel=..., ylabel=...). Given that Ultraplot’s current polar docs and API are framed in terms of theta/r formatters and locators rather than x/y axis labels, I do not think we should merge the Cartesian label behavior as part of this feature. I would be much more comfortable with this PR if it focused just on the polar-native label additions (thetalabel, rlabel, and related placement/styling options), dropped the xlabel/ylabel support, and added user-facing docs/examples for the new API. |
Add polar-aware rlabel and thetalabel support
Hi! I think having
rlabelandthetalabelfor polar plots is useful for manycases — Taylor diagrams being one example. I've added this support along with
tests. Let me know what you think!
Summary
This PR adds polar-aware axis label support to
PolarAxes.format()with newthetalabelandrlabelarguments rendered viaCurvedText.Key Features
thetalabelfor labels that follow the outer polar arc.rlabelfor labels that follow a radial spoke.thetalabellocto control the center angle of the theta label.rlabellocto control which side or spoke the radial label uses.rlabelposplacement for radial labels.thetalabel_kwandrlabel_kw.theta0,thetadir)Implementation
ultraplot/axes/polar.pyCurvedTextinultraplot/text.pyso transformed and styled curved labelsbehave correctly on polar axes
ultraplot/internals/labels.pyso border and bboxstyling can be applied safely to curved labels
Validation
Focused polar regression tests pass:
python -m pytest ultraplot/tests/test_projections.py -k "polar and not mpl_image_compare"This also adds regression coverage for:
thetalabeloutward placementExamples
Examples of full-circle, sector, annular, and rotated-axis polar labels: