Commit ec19455e authored by Yan's avatar Yan
Browse files

Fixed legends

parent aab01bf5
......@@ -210,7 +210,7 @@ def paint_override(self, augCanvas):
self.plot.set_ylim(augCanvas.spectplot.get_ylim())
data = [line.get_data() for line in augCanvas.spectplot.lines]
texts = copy.copy(augCanvas.ms)
if len(augCanvas.ms['headers']) != 0:
if augCanvas.ds.headers != []:
legend = augCanvas.spectplot.get_legend().get_texts()
[gt.pop_plot(*line, self.plot, texts, i, legend[i].get_text(),
not (cf.settings().value(
......
......@@ -20,6 +20,7 @@ class Dataset():
self.filename = rawfile
self.chromatograms = []
self.dataset = []
self.headers = []
self.timemin = -np.inf
self.timemax = np.inf
......@@ -52,7 +53,6 @@ class ThermoRawDataset(Dataset):
super().__init__(rawfile)
self.params = []
self.machtype = []
self.headers = []
self.refresh()
def refresh(self):
......
......@@ -250,7 +250,7 @@ def plot_subtime(augCanvas):
augCanvas.spectplot.set_xlim(slims[0])
if not cf.settings().value("view/autozoomy", type=bool):
augCanvas.spectplot.set_ylim(slims[1])
if not augCanvas.ms['headers'] == []:
if not augCanvas.ds.headers == []:
for ax in (augCanvas.spectplot, augCanvas.chromplot):
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
......@@ -391,7 +391,7 @@ def pop_plot(xdata, ydata, plot, plot_data, colornum=0, legend=None, annotate=Tr
plot.tick_params(axis='y', which='minor', left=False)
def legendize(rawlegend, chrom_data):
def legendize(rawlegend, augCanvas):
# sanity check
if len(rawlegend) == 0:
return None
......@@ -399,14 +399,14 @@ def legendize(rawlegend, chrom_data):
quads = ["q3", "q1"]
def translate(wut):
if chrom_data['machtype'] == 47:
if augCanvas.ds.machtype == 47:
if wut[1] in (0, 1):
text = "{}{}ms; m/z = {:.1f}-{:.1f}".format(
marks[int(wut[0])], quads[int(wut[1])], *wut[4:])
else:
text = "{}ms^{} {:.2f}@{:.1f}V; m/z = {:.1f}-{:.1f}".format(
marks[int(wut[0])], *wut[1:])
elif chrom_data['machtype'] in (57, 63):
elif augCanvas.ds.machtype in (57, 63):
if int(wut[1]) == 1:
text = "{}ms; m/z = {:.1f}-{:.1f}".format(
marks[int(wut[0])], *wut[2:])
......@@ -423,7 +423,7 @@ def legendize(rawlegend, chrom_data):
np.unique(np.array(rawlegend), axis=0, return_index=True)
strdata = [translate(i) for i in rawlegend[np.sort(uniqindexs[1])]]
strtext = " and\n".join(strdata) + "; t = {:.2f}-{:.2f} min".format(
chrom_data['t_start'], chrom_data['t_end'])
augCanvas.ds.timemin, augCanvas.ds.timemax)
return strtext
......@@ -450,16 +450,15 @@ def populate(augCanvas):
chromxy = augCanvas.ds.get_chromatograms()
msxy = augCanvas.ds.get_spectra()
for i in range(len(msxy)):
#if len(augCanvas.ds.headers) == len(augCanvas.ds.chromatograms):
if False:
legend = legendize(augCanvas.ds.headers[i], augCanvas.chrom)
if len(augCanvas.ds.headers) == len(augCanvas.ds.chromatograms):
legend = legendize(augCanvas.ds.headers[i], augCanvas)
else:
legend = None
pop_plot(msxy[i][0], msxy[i][1], augCanvas.spectplot, augCanvas.ms, i, legend)
pop_plot(chromxy[i][0], chromxy[i][1], augCanvas.chromplot,
augCanvas.chrom, i, legend)
for ax in (augCanvas.spectplot, augCanvas.chromplot):
if not augCanvas.ms['headers'] == []:
if not augCanvas.ds.headers == []:
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
ax.get_legend().set_visible(
......
......@@ -142,7 +142,7 @@ def pop_dial(augCanvas, drls, graph, labels, parselect):
colorargs = [row for row in range(drls['dt'].rowCount())
if drls['dt'].cellWidget(row, 0).checkState() == 2]
params = augCanvas.ms['params'][1]
headers = np.concatenate(augCanvas.ms['headers'], axis=0)
headers = np.concatenate(augCanvas.ds.headers, axis=0)
parlen = len(params)
if len(names) < 2:
return
......
Markdown is supported
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