Commit 97a0a913 authored by Yan's avatar Yan
Browse files

fixed minor glich in pan functionality ax detection

parent 19a0af05
......@@ -52,32 +52,33 @@ def zoom_factory(ax, base_scale, plot=None, an=None):
def pan_factory(ax, plot=None, an=None):
def pan_fun(event):
def pan_fun(event, ax):
if event.dblclick and event.inaxes == ax:
ax.get_figure()
ax.autoscale(True)
ax.set_ylim(ax.get_ylim()[1]*-0.01,ax.get_ylim()[1]*1.1)
annSpectr(spectrum, plot['x'], plot['y'], an)
ax.figure.canvas.draw()
elif event.button == 1 and event.inaxes == ax:
ax.start_pan(event.x, event.y, event.button)
id_drag = fig.canvas.mpl_connect('motion_notify_event', drag_fun)
id_drag = fig.canvas.mpl_connect('motion_notify_event', lambda action: drag_fun(action, ax))
id_release = fig.canvas.mpl_connect('button_release_event',
lambda action: drag_end(action, id_drag, id_release, plot, an))
lambda action: drag_end(action, id_drag, id_release, plot, an, ax))
def drag_fun(event):
def drag_fun(event, ax):
ax.drag_pan(1, 'x', event.x, event.y)
ax.figure.canvas.draw()
def drag_end(event, id_drag, id_release, plot, an):
def drag_end(event, id_drag, id_release, plot, an, ax):
if event.button == 1:
fig.canvas.mpl_disconnect(id_drag)
fig.canvas.mpl_disconnect(id_release)
if an != None:
if type(plot['x']) != type(None):
annSpectr(event.inaxes,plot['x'], plot['y'], an)
annSpectr(ax,plot['x'], plot['y'], an)
ax.figure.canvas.draw()
fig = ax.get_figure()
fig.canvas.mpl_connect('button_press_event', pan_fun)
fig.canvas.mpl_connect('button_press_event', lambda action: pan_fun(action, ax))
def pick_masses(xmin, xmax, ax, an, plot):
ax.set_xlim(xmin,xmax)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment