aboutsummaryrefslogtreecommitdiff
path: root/qolab/data/trace.py
diff options
context:
space:
mode:
Diffstat (limited to 'qolab/data/trace.py')
-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