When I create a custom applet to plot datasets using Matplotlib with Qt5Agg as the backend, I get an error processing data from the applet as follows:
ERROR:dashboard:artiq.gui.applets:error processing data from applet, server stopped
Traceback (most recent call last):
File "C:\Users\<USERNAME>\anaconda3\envs\artiq\lib\site-packages\artiq\gui\applets.py", line 57, in serve
obj = await self.read_pyon()
File "C:\Users\<USERNAME>\anaconda3\envs\artiq\lib\site-packages\artiq\gui\applets.py", line 34, in read_pyon
return pyon.decode(line.decode())
File "C:\Users\<USERNAME>\anaconda3\envs\artiq\lib\site-packages\sipyco\pyon.py", line 210, in decode
return eval(s, _eval_dict, {})
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
The applet command issued through the dashboard is: python "<PATH>\plot_experiment_data.py"
The code for the custom applet in plot_experiment_data.py
is as follows:
import matplotlib
import matplotlib.pyplot as plt
from PyQt5 import QtWidgets
from artiq.applets.simple import SimpleApplet
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
matplotlib.use('Qt5Agg')
class MplCanvas(FigureCanvasQTAgg):
def __init__(self):
fig, ax = plt.subplots()
self.axes = ax
super(MplCanvas, self).__init__(fig)
class ExperimentWidget(QtWidgets.QMainWindow):
def __init__(self, args):
super().__init__()
self.sc = MplCanvas()
self.setCentralWidget(self.sc)
self.sc.axes.spines['left'].set_position('center')
self.sc.axes.spines['right'].set_color('none')
self.sc.axes.spines['bottom'].set_position('center')
self.sc.axes.spines['top'].set_color('none')
plt.grid(True)
def data_changed(self, data, mods):
self.sc.axes.plot(data['xs'][1], data['sine'][1])
plt.show()
def main():
applet = SimpleApplet(ExperimentWidget)
applet.run()
if __name__ == "__main__":
main()
I couldn't glean much about this from the examples provided in ARTIQ, so I'm stuck as to how I can resolve this issue.