Commit 6fcfb05e authored by Yan's avatar Yan
Browse files

Renamed annotations array, fixed doubleclick error

renamed annotations in peack picking section
removed doubleclick bug which produces error when doubleclicked in
chromatogram
parent 19e56f2e
......@@ -52,20 +52,21 @@ def zoom_factory(ax, base_scale, plot=None, an=None):
return zoom_fun
def pan_factory(axis, plot=None, an=None):
def pan_factory(axis, plot=None, annotations=None):
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)
ann_spec(spectrum, plot['x'], plot['y'], an)
if annotations is not None:
ann_spec(ax, plot['x'], plot['y'], annotations)
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', 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, ax))
action, id_drag, id_release, plot, annotations, ax))
def drag_fun(event, ax):
ax.drag_pan(1, 'x', event.x, event.y)
......@@ -127,7 +128,7 @@ def populate(mpl_chromatogram, mpl_spectrum, data_set, time_sel, an, ms_s):
mpl_chromatogram.figure.canvas.draw()
mpl_spectrum.figure.canvas.draw()
def ann_spec(ms_spec, mass, intensity, an, ann_limit=0.01):
def ann_spec(ms_spec, mass, intensity, annotations, ann_limit=0.01):
def sub_peaks(peakz, x_value, y_value, x, y, coef_x=10, coef_y=10):
sp = sorted(peakz,
key=lambda h: y_value[h],
......@@ -164,14 +165,14 @@ def ann_spec(ms_spec, mass, intensity, an, ann_limit=0.01):
ms_spec.get_xlim()[1] - ms_spec.get_xlim()[0],
ms_spec.get_ylim()[1] - ms_spec.get_ylim()[0])
for j in an:
for j in annotations:
j.remove()
an.clear()
annotations.clear()
for i in s_peaks:
an.append(ms_spec.annotate('{0:.2f}'.format(mass[i]),
xy=(mass[i], intensity[i]),
textcoords='data'))
annotations.append(ms_spec.annotate('{0:.2f}'.format(mass[i]),
xy=(mass[i], intensity[i]),
textcoords='data'))
def spectrum_plot(spc, mass, intensity, an):
spc.plot(mass, intensity)
......
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