aboutsummaryrefslogtreecommitdiff
path: root/qolab
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-21 22:03:27 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-21 22:03:27 -0500
commit9f50b020ad607265d4e77516a648c197f9486aee (patch)
tree6b930e0fa7e149584f42bb8545af5df4202614ed /qolab
parent5796c26fa86dbd77bbd6caf5122961d4d49e78f5 (diff)
downloadpyExpControl-9f50b020ad607265d4e77516a648c197f9486aee.tar.gz
pyExpControl-9f50b020ad607265d4e77516a648c197f9486aee.zip
proper treatment of timestamped axis
Diffstat (limited to 'qolab')
-rw-r--r--qolab/data/trace.py14
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