From 65a220c30593c86cc2ea4291b794196146880e9d Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 3 Dec 2021 09:59:41 -0500 Subject: added grabing and ploting all traces capabilities --- qolab/data/trace.py | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'qolab/data') diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 9b14264..ef44041 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -1,16 +1,51 @@ - -class Trace: +class TraceYonly: def __init__(self, descrStr): self.descr = descrStr - self.x = None - self.xlabel = None - self.xunit = None self.y = None self.ylabel = None self.yunit = None + def plot(self): + import matplotlib.pyplot as plt + plt.plot(self.y, label=self.descr) + plt.legend() + + +class Trace(TraceYonly): + def __init__(self, descrStr): + super().__init__(descrStr) + self.x = None + self.xlabel = None + self.xunit = None + def plot(self): import matplotlib.pyplot as plt plt.plot(self.x, self.y, label=self.descr) plt.legend() +class TraceSetSameX: + def __init__(self, descrStr): + self.descr = descrStr + self.x = None + self.xlabel = None + self.xunit = None + self.traces={} + + def addTrace(self, tr): + if len(self.traces) == 0: + self.x = tr.x + self.xlabel = tr.xlabel + self.xunit = tr.xunit + trY = TraceYonly(tr.descr) + trY.y = tr.y + trY.ylabel = tr.ylabel + trY.yunit = tr.yunit + self.traces[trY.descr]=trY + + def plot(self): + import matplotlib.pyplot as plt + for k, v in self.traces.items(): + plt.plot(self.x, v.y, label=v.descr) + plt.legend() + + -- cgit v1.2.3