python - Animated stripchart using matplotlib in PyQt5 GUI -
i'm trying create interactive 4-channel stripchart in pyqt5 gui , i'm using matplotlib so. have matplotlib plot embedded gui widget, i'm trying make use of matplotlib.animate module in order plots update. keep getting keyerror when referring lines i've added axes. besides updating of plot functions expected far, i'm including code believe relevant.
class stripchartbuilder(qtwidgets.qdialog, stripchartdialog.ui_dialog): def __init__(self, ..., parent=none) self.fig = figure() self.ax1 = self.fig.add_subplot(111) self.addfigure() self.channels = {'ch 1': {'signal': 'none', 'scale': 'x1', 'cursor': false, 'data': [0], 'line': line2d(self.tdata, [0], color='r') }, ... } self.prevsig{'ch 1': 'none',...} def addfigure(self): self.canvas = figurecanvas(self.fig) self.canvas.draw() self.toolbar = navigationtoolbar(self.canvas, self.mplwindow, coordinates=true) self.mplvl.addwidget(self.toolbar) self.mplvl.addwidget(self.canvas) def update(self, i): print(self.ax1.lines) return [self.channels['ch 1']['line'] def addline(self, chan): self.ax1.add_line(self.channels[chan]['line']) self.ani = animation.funcanimation(self.fig, self.update, interval=10, blit=true)
basically idea have 4 channels on monitor things. have dictionary, channels each key corresponding 1 channel. line parameter each stores line2d object. when turn spinner under data item label besides 'none' add associated line plot. point seems work fine.i can add , remove lines like, problem can't animate.funcanimation work. i've stopped trying inside update method, because can't run @ all.
when addline method called setting 1 of spinners, program throws keyerror on, assume, i'm returning update method. added 2 prints in update in attempt try , debug what's going on. when print channels dictionary , self.ax1.lines both give me same address object, keyerror i'm encountering trying access else, , appears trying entirely different type of object.
for example:
print(self.ax1.lines) return:
[<matplotlib.lines.line2d object @ 0x0000000006f0dd68>]
the keyerror receive is:
keyerror: <matplotlib.axes._subplots.axessubplot object @ 0x0000000006d44be0>
i'm doing wrong, i'm not sure is. supposed returning in update method? problem is?
Comments
Post a Comment