From d44e964463134d8fcc0d196a802269a9f02d76b6 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 3 Dec 2021 18:50:50 -0500 Subject: get rid of descr attribute --- qolab/data/trace.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'qolab/data') diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 488bcfd..5b75fc1 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -1,8 +1,7 @@ class Trace: - def __init__(self, descrStr): - self.descr = descrStr + def __init__(self, label): + self.label = label self.values = None - self.label = None self.unit = None self.attributes = {} @@ -13,33 +12,33 @@ class Trace: class TraceXY: - def __init__(self, descrStr): - self.descr = descrStr - self.x = Trace('x_values') - self.y = Trace('y_values') + def __init__(self, label): + self.label = label + self.x = None + self.y = None def plot(self): import matplotlib.pyplot as plt - plt.plot(self.x.values, self.y.values, label=self.descr) + plt.plot(self.x.values, self.y.values, label=self.label) plt.legend() plt.xlabel(self.x.label) class TraceSetSameX: - def __init__(self, descrStr): - self.descr = descrStr - self.x = Trace('x_values') + def __init__(self, label): + self.label = label + self.x = None self.traces={} def addTrace(self, tr): if len(self.traces) == 0: self.x = tr.x trY = tr.y - self.traces[tr.descr]=trY + self.traces[tr.label]=trY def plot(self): import matplotlib.pyplot as plt for k, tr in self.traces.items(): - plt.plot(self.x.values, tr.values, label=tr.descr) + plt.plot(self.x.values, tr.values, label=tr.label) plt.xlabel(self.x.label) plt.legend() @@ -49,9 +48,9 @@ class TraceSetSameX: def keys(self): return (self.traces.keys()) - def getTrace(self, name): - tr = TraceXY(name) + def getTrace(self, label): + tr = TraceXY(label) tr.x = self.x - tr.y = self.traces[name] + tr.y = self.traces[label] return (tr) -- cgit v1.2.3