From 26a6e8c5dee9dadcf18f08fc42d150a8aa66ed72 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 10 Jan 2016 18:23:31 +0800 Subject: [PATCH] gui/applets: add histogram plot --- artiq/applets/plot_hist.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 artiq/applets/plot_hist.py diff --git a/artiq/applets/plot_hist.py b/artiq/applets/plot_hist.py new file mode 100755 index 000000000..cfaf6a36c --- /dev/null +++ b/artiq/applets/plot_hist.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3.5 + +import numpy as np +import pyqtgraph + +from artiq.applets.simple import SimpleApplet + + +class HistogramPlot(pyqtgraph.PlotWidget): + def __init__(self, args): + pyqtgraph.PlotWidget.__init__(self) + self.args = args + + def data_changed(self, data, mods): + try: + y = data[self.args.y][1] + if self.args.x is None: + x = None + else: + x = data[self.args.x][1] + except KeyError: + return + if x is None: + x = list(range(len(y)+1)) + + if len(y) and len(x) == len(y) + 1: + self.clear() + self.plot(x, y, stepMode=True, fillLevel=0, + brush=(0, 0, 255, 150)) + + +def main(): + applet = SimpleApplet(HistogramPlot) + applet.add_dataset("y", "Y values") + applet.add_dataset("x", "X values", required=False) + applet.run() + +if __name__ == "__main__": + main()