New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: ignore axes that aren't visible #16175
FIX: ignore axes that aren't visible #16175
Conversation
6ab4d31
to
8a12e8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll trust you that it fixes the issue reported on SO, but this certainly makes sense.
Is there an easy way to test button clicks? |
It's slightly a pain, see
|
added test in |
Due to the fix from f215d09 this is fine. Though in general, I think not having any extra axes in the game would be much better. |
Not easily. The layout boxes used by constrained layout are attributes of the axes. You could imagine re-architecting the whole thing so the layout box was the attribute of some sort of subplotspec object, but we don't have those (the axes also keeps track of its subplotspec). I don't think its too bad a hack, but certainly if we re-architect all the layout engines it should be considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could imagine other problems occuring because of extra axes being present in the figure.
Maybe in the longer run one could imagine constrained_layout keeping track of the axes it needs, without them necessarily being part of the figure?
In any case, this fixes the bug, so approving as is.
98c06ca
to
9f8235e
Compare
""" | ||
axes_list = [a for a in self.figure.get_axes() | ||
if a.patch.contains_point(xy)] | ||
|
||
if a.patch.contains_point(xy) and a.get_visible()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps reverse the order of the checks? get_visible() should be faster (just an attribute check) than contains_point()
@jklymak can self-merge with or without this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first check is to make sure the pick is actually in the axes (because its in pixels). So if the second check failed, and you didn't have the first, you wouldn't know if it failed because of a resolution change in the tests or because the functionality actually broke.
In normal conditions both tests should pass, so I don't think there is a typical time savings here.
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
…3.2.x Backport PR #16175: FIX: ignore axes that aren't visible
PR Summary
Closes #16173
Layering subplots causes the topmost subplot to capture mouse events, which seems fine. However, if the topmost subplot is made invisible (which is a trick we use in
cosntrained_layout
) then it would still capture the mouse event. Given that an axes withax.get_visble() is False
is never drawn, not are any of its children, it seem unlikely that anyone would want to pick on a placeholder like that so the son here is to ignore invisible axes.Note that I also changed how
constrained_layout
makes the axes invisible. It passes all the tests, so this is preferable to the way I was doing it before.Test
PR Checklist