-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ENH: allow changing the Axes sort order for event handling #2986
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
Conversation
I realize this will need a whats_new entry etc., but I want to first find out whether anyone sees any problem with this approach. |
LGTM 👍 |
I think this looks like a fine way to do this. |
Previously, when a second axes is created using twinx, for example, that axes catches all events; cursor position is shown based on that axes, etc. The Figure.swap_axes_order() method allows one to exchange the sorting indices of the two axes, so that the first axes can process events instead of the second one.
This changeset also handles swapping patch visibility.
This is getting close to being ready, based on the present approach, but it raises some questions. The main problem is that the Axes stack order determines which Axes gets the mouse events, and it also determines the order in which Axes are drawn--unless one overrides this with Axes zorder. Typically this is not done, so swapping Axes requires swapping their positions in the stack, and swapping the visibility attribute of their patches. In the second changeset, I added that functionality to swap_axes_order. This will not be the desired result, however, if zorder is being used to determine the Axes drawing order; in that case, for shared axes, only the one with the lowest zorder should have a visible patch. |
This may be a dumb question (I have not dug around in this section of the code recently), but why don't we just raise mouse events for all axes that the mouse is in and let the event handlers sort out if they want to handle the event? |
I think that would be even harder to manage; for example, how would you determine what gets displayed in the cursor position readout? |
I would want display the location in all of the axes that the cursor is in. I think that could be done tacking an extra dict on to the canvas object and making |
On 2014/05/04 11:14 AM, Thomas A Caswell wrote:
That would require a different scheme for fitting them into the window, |
My thought was much lazier, either ask the axes object their gid or just label them sequentially and keep them all on one line:
I don't think this would require touching anything outside of backend_bases.py |
I'm reluctant to include this in 1.4 because it sounds like you might have a better approach, @tacaswell . I don't want to introduce an API change unless we are confident that it is what we want for the long term. |
Fair enough. I re-tagged this issue. |
It looks like you could use |
Looks like it's time to abandon this one. |
Previously, when a second axes is created using twinx, for example,
that axes catches all events; cursor position is shown based on
that axes, etc. The Figure.swap_axes_order() method allows one to
exchange the sorting indices of the two axes, so that the first
axes can process events instead of the second one.