From 8ada9f076662c0238110b1c4402cb60a3530a859 Mon Sep 17 00:00:00 2001 From: CPD Date: Wed, 5 Mar 2025 10:27:27 +0100 Subject: [PATCH] Add clear method --- app/ui/widgets/plot.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/ui/widgets/plot.py b/app/ui/widgets/plot.py index 06e4a07..e427f7b 100644 --- a/app/ui/widgets/plot.py +++ b/app/ui/widgets/plot.py @@ -59,13 +59,36 @@ class Plot(pg.GraphicsLayoutWidget): self.v_plot_item.getViewBox().sigResized.connect(self.update_views) def update_views(self): + """ + Make sure the linked view boxes have the correct size + (called after resizing of the plot) + """ self.l_box.setGeometry(self.v_plot_item.getViewBox().sceneBoundingRect()) self.l_box.linkedViewChanged(self.v_plot_item.getViewBox(), self.l_box.XAxis) def update_plot(self, time, voltage, led): + """ + Add new data points to the plot + Parameters + ---------- + time + voltage + led + """ self.time.append(time) self.voltage.append(voltage) self.led.append(led) self.v_line.setData(self.time, self.voltage) self.l_line.setData(self.time, self.led) + + def clear_data(self): + """ + Clear the lines and data + Returns + """ + self.time = [] + self.voltage = [] + self.led = [] + self.v_line.setData(self.time, self.voltage) + self.l_line.setData(self.time, self.led) \ No newline at end of file