Simplify cla sharex/sharey code; alternative to #8710#8720
Simplify cla sharex/sharey code; alternative to #8710#8720tacaswell merged 1 commit intomatplotlib:masterfrom
Conversation
|
Obviously we may be constrained by backcompat, but it is not clear to me why we'd expect |
|
Notice that this is in the context of a shared axis, say the x-axis being shared between Axes A and B. You start by making A, setting its scale, locators, and formatters. Then you make B, sharing it with A. This calls B.cla(). What the code is doing is making B.xaxis.major refer to A.xaxis.major; these are Ticker instances, which are just references to a locator and a formatter (and the same for .minor). So this is the somewhat indirect and obscure way that the sharing of locators and formatters is done (contrary to a comment in the tickers module that locator instances should not be shared, if I remember correctly). But the short answer to your question is that in this context, with a shared axis, cla is not resetting the scale, it is just setting it to match that of the axes with which it is shared. Now, this works correctly on initialization of B, but I just did a little test, calling B.cla() after plotting in A and B, and, with 2.0.2, it did not do the right thing--it preserved the x scale (which I had changed to log), but it reset the locator and formatter to the linear defaults. I think this is a bug, perhaps related to the earlier unconditional call to self.xaxis.cla() in B.cla(). |
|
OK, I understand your explanation. |
|
@anntzer I would prefer to have this PR go in as-is; I think it provides a little bit of cleanup with no side-effects (unless I am missing something), and is only peripherally related to the bug. I have been digging in to the sharing and aspect ratio business a bit, and the bug is just one part of that. I'm not sure whether it will make sense to fix it independently, or as part of a larger set of changes. I suspect the latter. |
PR Summary
PR Checklist