Is it possible to bind the scroll wheel to zoom in/out when the cursor is hovering over a matplotlib plot?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should work. It re-centers the graph on the location of the pointer when you scroll.
Assuming you have an axis object
axThe optional argument
base_scaleallows you to set the scale factor to be what ever you want.make sure you keep a copy of
faround. The call back uses a weak-ref so if you do not keep a copy offit might be garbage collected.After writing this answer I decided this actually quite useful and put it in a gist