[WIP] axes_grid1: make twin* not modify host axes - #13092
smheidrich wants to merge 1 commit into
Conversation
|
@jklymak Sorry, I should've specified that the images come from the
I'm not sure what you mean by that; parent (i.e. host) axes removal isn't part of the test and I think is also unchanged by this PR. This PR only changes how the various
That sounds great! I'll have to look into it. |
|
OK, thanks - sorry missed that this is I don't see why the spine would be made invisible on either parent or twin at all, but no doubt I'm not following it closely enough. That is a pretty long issue chain. Is it that over-plotting the spine looks bad in some way? |
|
@jklymak I think the decision to have only one axisline goes back even further than #4898 let alone this PR here; all #4898 did was to make the decision which one gets hidden consistent between Regarding drawing both axislines on top of each other, here is what that would look like (2nd row): In my opinion, it is noticeable and does look a bit bad. |
8f793f7 to
a54f4c7
Compare
|
It is noticeable, but I wonder why? Aren't they both lines drawn at the same value of y? Is it bad in all backends, and does it get less bad with higher dpi? I wonder in @anntzer mpl_cairo looks bad... EDIT: looks like the anti-aliasing kicking in twice? i.e. the shading is darker around the full-black part of the line? |
|
Overdrawing a line twice will always look not-so-great in the presence of antialiasing; pretty sure mplcairo would give you the same results (not that I tried). |
2d25e62 to
e499b2f
Compare
PR matplotlib#4898 changed the behavior of twinx() and twiny() in axes_grid1 to make them consistent with twin(). This commit inverts the "direction" of consistency and makes twin() behave like the pre-matplotlib#4898 twinx() and twiny() instead. This way, the API becomes less surprising: instead of hiding certain host axes, twin* now keeps the host axes unmodified, while the parasite axes have their axis lines hidden instead. Unfortunately, this change breaks backwards-compatibility for code relying on the specifics of host and parasite axes visibility. Helps with matplotlib#10748.
e499b2f to
23a3b6e
Compare
|
OK, so given this, I agree that it makes sense to have the twin be the one that doesn't draw its spine. I don't know the twinx behaviour well enough, but is the axis always over top of the parent spine? If not, then does it know if its displaced so it can make the spine visible? Otherwise I think this change of behaviour is good. |
|
Sorry for the long inactivity.
The only example of displaced parasite axes I know of is the The line directly above it had to be introduced after #4898 broke the example, and could in principle be removed again given the changes in this PR (although it doesn't do harm to leave it in, either). |
|
@smheidrich This didn't get any follow up, but still seems useful. Feel free to revive! |
|
I think all that was left to do here was check whether all the gallery and doc examples are definitely unaffected by the changes in this PR (because the original PR that this one partially corrects messed something up). They're still not part of the baseline-comparison CI tests, are they? |
|
No, but if there's something that fails there, it should probably be added to the tests. However, docs (including most examples) are built as part of CI. |


PR Summary
PR #4898 changed the behavior of twinx() and twiny() in axes_grid1 to make them consistent with twin(). This commit inverts the "direction" of consistency and makes twin() behave like the pre-#4898 twinx() and twiny() instead. This way, the API becomes less surprising: instead of hiding certain host axes, twin* now keeps the host axes unmodified, while the parasite axes have their axis lines hidden instead (cf. images below).
Unfortunately, this change breaks backwards-compatibility for code relying on the specifics of host and parasite axes visibility.
Helps with #10748.
Relevant image comparison test
The effect of this PR is best illustrated by comparing the results of the
test_axes_grid1.test_twin_axes_empty_and_removedimage comparison test:Pre-PR behavior
Post-PR behavior
PR Checklist