Correctly set formatters and locators on removed shared axis#14997
Correctly set formatters and locators on removed shared axis#14997tacaswell merged 1 commit intomatplotlib:masterfrom
Conversation
|
Ok so I think this is a case of sharex=True meaning too many things. Are we garaunteeibg that sharing the axis means we are sharing the locators and formatters? That seems really hard to enforce and when you toss units into the mess, it becomes almost intractable. I agree that just removing an axis shouldn’t cause a crash, but I think the fundamental issue is that the locators and formatters were linked in the first place. |
At least IIRC @efiring has a fairly strong opinion that we do... |
| axis.set_major_formatter(majfmt) | ||
| if isDefault: | ||
| majfmt.axis.isDefault_majfmt = True | ||
|
|
There was a problem hiding this comment.
This doesn't make any sense to me. You get the formatter for axis and then you set the formatter for axis to that formatter, and then you set the isDefault to the value axis had before. I don't see how this code is doing anything.
There was a problem hiding this comment.
I think the confusion here stems from the mappings of formatters to axis.
- Axis > Formatter is a one to one mapping
- Formatter > Axis is a one to many mapping
So a single Formatter is linked to a single Axis, but many other Axis can make use of that Formatter. I agree this is a nightmare to understand, but without re-doing the internals of how this works it is how it is.
So this code is getting the formatter that axis is using, (that it might be borrowing) and then explicitly associating that formatter with axis (so it is no longer borrowing it).
|
I appreciate this is messy code, but it is neccesitated by the weird way that
I think 2. is a bit much to do for |
fe858aa to
1d71f21
Compare
|
Be good to rebase to double check that docs build, but I don't think that has anything to do w/ this PR. |
1d71f21 to
24d1837
Compare
Fixes #14911
The issue was that a shared axis might never have it's
Formatter/Locatorset, which is fine when it is shared, but when the axis storing theFormatter/Locatorit relies on is removed, the previous shared axis needs to have theFormatter/Locators set.Also fixed typo
_reset_axis_form>_reset_axis_from.I've tried a few things, but cannot come up with a more elegant solution than this; if anyone has any ideas suggestions welcome.