From 9e886376eba4dc884ed887fd09062882f7088e8b Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Tue, 21 Dec 2021 23:17:00 -0500 Subject: redone plotting of TraceSetSameX so it does not show xtics everywhere --- qolab/data/trace.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'qolab') diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 681a89a..37387fa 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -241,21 +241,18 @@ class TraceSetSameX(Trace): def plot(self): import matplotlib.pyplot as plt nplots = len(self.traces.keys()) + fig, axs = plt.subplots(nplots, 1, sharex=True) cnt=0 x=self.x.values 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(): + p=axs[cnt].plot(x, tr.values, label=k) + axs[cnt].set_ylabel(f"{tr.config['label']} ({tr.config['unit']})") + axs[cnt].legend() + axs[cnt].grid() cnt+=1 - if cnt == 1: - ax1=plt.subplot(nplots, 1, cnt) - else: - plt.subplot(nplots, 1, cnt, sharex=ax1) - plt.plot(x, tr.values, label=k) - plt.ylabel(f"{tr.config['label']} ({tr.config['unit']})") - plt.legend() - plt.grid() plt.xlabel(f"{self.x.config['label']} ({self.x.config['unit']})") def items(self): -- cgit v1.2.3