From 356afb045c36d88ee41b712666d87db92a81f6e4 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 6 Apr 2016 17:08:38 +0800 Subject: [PATCH] applets: support title for histogram and XY. Closes #376 --- artiq/applets/plot_hist.py | 7 ++++--- artiq/applets/plot_xy.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/artiq/applets/plot_hist.py b/artiq/applets/plot_hist.py index ff77365fc..3f46ffa1e 100755 --- a/artiq/applets/plot_hist.py +++ b/artiq/applets/plot_hist.py @@ -4,7 +4,7 @@ import numpy as np import PyQt5 # make sure pyqtgraph imports Qt5 import pyqtgraph -from artiq.applets.simple import SimpleApplet +from artiq.applets.simple import TitleApplet class HistogramPlot(pyqtgraph.PlotWidget): @@ -12,7 +12,7 @@ class HistogramPlot(pyqtgraph.PlotWidget): pyqtgraph.PlotWidget.__init__(self) self.args = args - def data_changed(self, data, mods): + def data_changed(self, data, mods, title): try: y = data[self.args.y][1] if self.args.x is None: @@ -28,10 +28,11 @@ class HistogramPlot(pyqtgraph.PlotWidget): self.clear() self.plot(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 150)) + self.setTitle(title) def main(): - applet = SimpleApplet(HistogramPlot) + applet = TitleApplet(HistogramPlot) applet.add_dataset("y", "Y values") applet.add_dataset("x", "Bin boundaries", required=False) applet.run() diff --git a/artiq/applets/plot_xy.py b/artiq/applets/plot_xy.py index 413d90cb2..1df60cb97 100755 --- a/artiq/applets/plot_xy.py +++ b/artiq/applets/plot_xy.py @@ -4,7 +4,7 @@ import numpy as np import PyQt5 # make sure pyqtgraph imports Qt5 import pyqtgraph -from artiq.applets.simple import SimpleApplet +from artiq.applets.simple import TitleApplet class XYPlot(pyqtgraph.PlotWidget): @@ -12,7 +12,7 @@ class XYPlot(pyqtgraph.PlotWidget): pyqtgraph.PlotWidget.__init__(self) self.args = args - def data_changed(self, data, mods): + def data_changed(self, data, mods, title): try: y = data[self.args.y][1] except KeyError: @@ -38,6 +38,7 @@ class XYPlot(pyqtgraph.PlotWidget): self.clear() self.plot(x, y, pen=None, symbol="x") + self.setTitle(title) if error is not None: # See https://github.com/pyqtgraph/pyqtgraph/issues/211 if hasattr(error, "__len__") and not isinstance(error, np.ndarray): @@ -49,7 +50,7 @@ class XYPlot(pyqtgraph.PlotWidget): def main(): - applet = SimpleApplet(XYPlot) + applet = TitleApplet(XYPlot) applet.add_dataset("y", "Y values") applet.add_dataset("x", "X values", required=False) applet.add_dataset("error", "Error bars for each X value", required=False)