Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

efiring
Copy link
Member

@efiring efiring commented Apr 18, 2014

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.

@efiring
Copy link
Member Author

efiring commented Apr 18, 2014

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.
If not, a possible addition would be to add a kwarg to twinx and twiny to control whether this swapping occurs automatically.

@cimarronm
Copy link
Contributor

LGTM 👍

@tacaswell
Copy link
Member

I think this looks like a fine way to do this.

@tacaswell tacaswell added this to the v1.4.0 milestone Apr 19, 2014
efiring added 2 commits May 4, 2014 09:33
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.
@efiring
Copy link
Member Author

efiring commented May 4, 2014

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 fragile coupling between drawing order and mouse event order is awkward and confusing.

@tacaswell
Copy link
Member

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?

@efiring
Copy link
Member Author

efiring commented May 4, 2014

I think that would be even harder to manage; for example, how would you determine what gets displayed in the cursor position readout?
(Travis failures look odd, but unrelated.)

@tacaswell
Copy link
Member

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 mouse_move a bit smarter.

@efiring
Copy link
Member Author

efiring commented May 4, 2014

On 2014/05/04 11:14 AM, Thomas A Caswell wrote:

I would want display the location in /all/ of the axes that the cursor
is in.

That would require a different scheme for fitting them into the window,
and for labeling them. The readout region would have to expand
vertically to make room; one would want them in a stack. All doable,
but it would mean changing all interactive backends. I agree that it
might be a nice improvement.

@tacaswell
Copy link
Member

My thought was much lazier, either ask the axes object their gid or just label them sequentially and keep them all on one line:

ax1: format_coord(...) | ax2: format_coord(...)

I don't think this would require touching anything outside of backend_bases.py

@efiring
Copy link
Member Author

efiring commented Jun 1, 2014

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.

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.0 Jun 1, 2014
@tacaswell
Copy link
Member

Fair enough. I re-tagged this issue.

@blink1073
Copy link
Member

It looks like you could use ax._shared_x_axes.get_siblings(ax) and ax._shared_y_axes.get_siblings(ax) in mouse_move and add messages for all siblings.

@tacaswell tacaswell modified the milestones: proposed next point release, next point release Feb 19, 2015
@efiring
Copy link
Member Author

efiring commented Jun 21, 2015

Looks like it's time to abandon this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants