Hi,
Here is a simple example of how to use Matplotlib in a GUI applet, for
people who prefer this plotting library. Note that Matplotlib is very
slow compared to pyqtgraph, and on a low-end PC it will take a few
seconds to update a simple plot.
Use this command in the applets dock:
/path/matplotdemo.py --embed {embed_token} flopping_f_brightness
Applet support is not available in the master branch/conda packages yet
as it requires Qt5 that Anaconda does not provide; you must use the Git
source for now.
Sebastien
#!/usr/bin/env python3.5
import matplotlib
matplotlib.use("Qt5Agg")
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from artiq.applets.simple import SimpleApplet
class Matplot(FigureCanvas):
def __init__(self, args, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
self.axes.hold(False)
FigureCanvas.__init__(self, fig)
self.args = args
def data_changed(self, data, mods):
try:
y = data[self.args.dataset][1]
except KeyError:
pass
self.axes.plot(y)
self.draw()
def main():
applet = SimpleApplet(Matplot, default_update_delay=4.0)
applet.add_dataset("dataset", "dataset to show")
applet.run()
if __name__ == "__main__":
main()
_______________________________________________
ARTIQ mailing list
https://ssl.serverraum.org/lists/listinfo/artiq