diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-21 22:03:27 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-21 22:03:27 -0500 |
commit | 9f50b020ad607265d4e77516a648c197f9486aee (patch) | |
tree | 6b930e0fa7e149584f42bb8545af5df4202614ed /qolab/data/trace.py | |
parent | 5796c26fa86dbd77bbd6caf5122961d4d49e78f5 (diff) | |
download | qolab-9f50b020ad607265d4e77516a648c197f9486aee.tar.gz qolab-9f50b020ad607265d4e77516a648c197f9486aee.zip |
proper treatment of timestamped axis
Diffstat (limited to 'qolab/data/trace.py')
-rw-r--r-- | qolab/data/trace.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 9630184..681a89a 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -119,7 +119,11 @@ class Trace: def plot(self): import matplotlib.pyplot as plt - plt.plot(self.values, label=self.config['label']) + x=self.values + if self.config['type'] is not None: + if self.config['type'] == 'timestamp': + x = from_timestamps_to_dates(self.values) + plt.plot(x, label=self.config['label']) plt.xlabel('index') plt.ylabel(f"{self.config['unit']}") plt.legend() @@ -170,8 +174,8 @@ class TraceXY(Trace): def plot(self): import matplotlib.pyplot as plt x=self.x.values - if self.config['type'] is not None: - if self.config['type'] == 'timestamp': + if self.x.config['type'] is not None: + if self.x.config['type'] == 'timestamp': x = from_timestamps_to_dates(x) plt.plot(x, self.y.values, label=self.config['label']) plt.xlabel(f"{self.x.config['label']} ({self.x.config['unit']})") @@ -239,8 +243,8 @@ class TraceSetSameX(Trace): nplots = len(self.traces.keys()) cnt=0 x=self.x.values - if self.config['type'] is not None: - if self.config['type'] == 'timestamp': + if self.x.config['type'] is not None: + if self.x.config['type'] == 'timestamp': x = from_timestamps_to_dates(x) for k, tr in self.traces.items(): cnt+=1 |