forked from M-Labs/artiq
1
0
Fork 0

applets: support title for histogram and XY. Closes #376

This commit is contained in:
Sebastien Bourdeauducq 2016-04-06 17:08:38 +08:00
parent 485f82b53b
commit 356afb045c
2 changed files with 8 additions and 6 deletions

View File

@ -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()

View File

@ -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)