You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on adding touch-to-drag and pinch-to-zoom support for matplotlib. It is in general working but there are a few things to add before I submit a pull request. Wanted to get the conversation started though on a few points, and ask for any general input from the community.
Specific points:
Is this a good idea (I can't think of a reason it wouldn't be, but advise)
Should it be a toggle-able feature, for example in the rcParams? (I can't really think of a reason it should be, but maybe there is a use case in which people want touches to behave as mouse input)
Pinch to zoom in my implementation keeps the same points on the plot under your finger. So x and y axes rescale independently and aspect ratio changes as you move the two touches. Sounds reasonable? (this is intuitive to me)
Key input should hold x, y, aspect ratio (ctrl) as it does for current interactive mode. But maybe there should be some other situations in which we hold x,y: for example if the two touches are at approximately the same y-value, small changes in their y-location will lead to huge scale changes for the y-axis. So maybe if the touches are sufficiently close on an axis, that axis should be locked?
I think touchscreen vs trackpad are handled differently. With my current setup (qt5, Linux) multitouch events on my trackpad simply get translated to scroll events, unlike touchscreen events which come from Qt as QTouchEvent class. Agree though, it would be nice to have multitouch trackpad support as more users are likely to have that. Since physically a multitouch touchscreen event and a multitouch trackpad event are different (touchscreen event corresponds to some actual screen locations), I have a feeling they may have to be handled separately--but they do both sound useful.
It is pretty backend independent, though I don't know how much the kivy backend inherits from matplotlib. Currently in my code the actual handling of the touches, zooming, panning, etc happens in backend_bases.py, in FigureCanvasBase and NavigationToolbar2. So individual backends just have to make a container of the touch events and their locations, and base code will handle them generally (similarly to how other interaction events, like mouse events, are handled).
At least for Qt it is trivial to turn off--there is a "accept touch events" flag that can be set, to determine whether they should be interpreted as touches or mouse events. So setting up such a knob should not be hard.
I just took a look at the kivy backend source--looks like its classes do inherit from NavigationToolbar2 and FigureCanvasBase, so it should be easy to set up that backend to use pinch-to-zoom and touch to drag functionality from here. I think it will actually be especially cool for kivy since that framework likes multitouch environments!
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
I don't have a touch screen, but at least a multitouch touch pad that supports gestures which could be plumbed in there. I have a rough idea of how to implement in GTK, but not the other backends, and I guess we'd perhaps need to have a think about how to expose this API across backends.
Just chiming in to offer my support. Having touchpad gestures enabled would be fantastic, especially because now it is quite uncomfortable to navigate a plot without using an external mouse (the combination right click + drag is very cumbersome on a touchpad).
Activity
tacaswell commentedon Jan 11, 2017
How does touch-screen handling relate to mulit-touch trackpad handling? I suspect that will be a much larger user base than actual touch screen users.
Can you do this in a backend-independent way? There is a kivy backend (maintained externally).
Putting a knob to turn it off seems reasonable (I suspect it will be a conditional on hooking up some event handlers?).
Have not thought about this enough to have reasonable opinions about 3 and 4.
GregDMeyer commentedon Jan 11, 2017
I think touchscreen vs trackpad are handled differently. With my current setup (qt5, Linux) multitouch events on my trackpad simply get translated to scroll events, unlike touchscreen events which come from Qt as QTouchEvent class. Agree though, it would be nice to have multitouch trackpad support as more users are likely to have that. Since physically a multitouch touchscreen event and a multitouch trackpad event are different (touchscreen event corresponds to some actual screen locations), I have a feeling they may have to be handled separately--but they do both sound useful.
It is pretty backend independent, though I don't know how much the kivy backend inherits from matplotlib. Currently in my code the actual handling of the touches, zooming, panning, etc happens in
backend_bases.py, inFigureCanvasBaseandNavigationToolbar2. So individual backends just have to make a container of the touch events and their locations, and base code will handle them generally (similarly to how other interaction events, like mouse events, are handled).At least for Qt it is trivial to turn off--there is a "accept touch events" flag that can be set, to determine whether they should be interpreted as touches or mouse events. So setting up such a knob should not be hard.
tacaswell commentedon Jan 11, 2017
👍 that all sounds perfectly reasonable.
tacaswell commentedon Jan 11, 2017
attn @andnovar Given your work on kivy, you may have some insight on this.
GregDMeyer commentedon Jan 12, 2017
I just took a look at the kivy backend source--looks like its classes do inherit from NavigationToolbar2 and FigureCanvasBase, so it should be easy to set up that backend to use pinch-to-zoom and touch to drag functionality from here. I think it will actually be especially cool for kivy since that framework likes multitouch environments!
github-actions commentedon Apr 5, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
tacaswell commentedon Apr 5, 2023
I think this is still of interest and I think touch screens are more common now than they were in 2017 (well, I now have one).
QuLogic commentedon Apr 5, 2023
I don't have a touch screen, but at least a multitouch touch pad that supports gestures which could be plumbed in there. I have a rough idea of how to implement in GTK, but not the other backends, and I guess we'd perhaps need to have a think about how to expose this API across backends.
andnovar commentedon Apr 5, 2023
francescoboc commentedon May 10, 2023
Just chiming in to offer my support. Having touchpad gestures enabled would be fantastic, especially because now it is quite uncomfortable to navigate a plot without using an external mouse (the combination right click + drag is very cumbersome on a touchpad).