I am using ginput
for a graphic selection of a few points along a time signal. Sometimes, when the signal is too dense it might be useful to zoom over an area before making the selection of points. My problem is that it seems that the zoom to rectangle
option seems to be accounted for in ginput
.
For instance, with this sample code:
from __future__ import print_function
from pylab import arange, plot, sin, ginput, show
import numpy as np
t = np.linspace(0,25,500)
plot(t, sin(t))
x = ginput(3)
print("clicked",x)
show()
If I zoom over a portion of the signal, the clicks made for the zoom area selection are accounted for in ginput
... Is there a way to avoid this and make the zoom area selection independent from ginput
?
I was having the same issue and my fix was to write a function to zoom with the mouse wheel so I could zoom without clicking. I got the function from this page:
Matplotlib plot zooming with scroll wheel
and modified the function so that it was not zoomed past the original x and y limits:
So for a given figure:
As I did not get any answer and I could not find much on the topic, here is how I solved this problem: I added a pre-procedure allowing the user to zoom in over a chosen area. When the area is suitable for point picking, the user simply has to press "Enter" and go on with
ginput
.