On polar axes, autoscaling (which only applies on the radial direction) normally avoids moving the origin away from r=0 (unless there's negative radius data). However, this behavior is lost if set_rticks has been called first.
I think the problem is that set_rticks replaces the RadialLocator with the FixedLocator. The view_limits method on the RadialLocator is what usually keeps the origin at or below zero.
@rcomer yes. I have already altered my solution to one that uses the RadialLocator, very similar to what you proposed and it seems to work. Should i open a new PR or just commit to the branch in my fork? Sorry im not sure how it works. Thanks for the help
Activity
Fix matplotlib#29528 set_rticks makes autoscale move the origin away …
Fix matplotlib#29528 set_rticks makes autoscale move the origin away …
Fix matplotlib#29528 set_rticks makes autoscale move the origin away …
rcomer commented on Mar 24, 2025
I think the problem is that set_rticks replaces the RadialLocator with the FixedLocator. The view_limits method on the RadialLocator is what usually keeps the origin at or below zero.
matplotlib/lib/matplotlib/projections/polar.py
Lines 506 to 511 in a9dc9ac
Do we need to implement a RadialFixedLocator?
timhoffm commented on Mar 24, 2025
The RadialLocator is a wrapper around a base locator. Would it work to set RadialLocator.base to the FixedLocator?
rcomer commented on Mar 25, 2025
Oh, maybe we just need to call self.yaxis._wrap_locator_formatter within set_rticks
matplotlib/lib/matplotlib/projections/polar.py
Lines 722 to 725 in a9dc9ac
@bruswaine do you want to give that a try?
bruswaine commented on Mar 25, 2025
@rcomer yes. I have already altered my solution to one that uses the RadialLocator, very similar to what you proposed and it seems to work. Should i open a new PR or just commit to the branch in my fork? Sorry im not sure how it works. Thanks for the help
rcomer commented on Mar 25, 2025
@bruswaine great - it seems you are ahead of me! It's fine to commit to your existing branch.
Fix matplotlib#29528 set_rticks makes autoscale move the origin away …
Fix matplotlib#29528 set_rticks makes autoscale move the origin away …
Ensure polar plot radial lower limit remains at 0 after set_rticks + …