Self.line1_tail = Line2D(,, color='red', linewidth=2) Self.n = np.linspace(0, self.xlim - 1, self.xlim) MyDataLoop = threading.Thread(name = 'myDataLoop', target = dataSendLoop, daemon = True, args = (self.addData_callbackFunc,))Ĭlass CustomFigCanvas(FigureCanvas, TimedAnimation): Self.LAYOUT_A.addWidget(self.myFig, *(0,1)) Self.LAYOUT_A.addWidget(self.zoomBtn, *(0,0)) Self.zoomBtn = QtGui.QPushButton(text = 'zoom') X.setMaximumSize(QtCore.QSize(width, height))Ĭlass CustomMainWindow(QtGui.QMainWindow): X.setMinimumSize(QtCore.QSize(width, height)) tHeightForWidth(x.sizePolicy().hasHeightForWidth()) # EMBED A MATPLOTLIB ANIMATION INSIDE YOUR #įrom matplotlib.animation import TimedAnimationįrom _qt4agg import FigureCanvasQTAgg as FigureCanvas Nevertheless, I've made some code a while ago to plot live graphs, that I would like to share:Ĭode for PyQt4: # I know I'm a bit late to answer this question. Str(doblit), niter / (time.time() - tic)) alpha) * gen.randn(2, n) * sigma + alpha * old_deltaĭisplay the simulation using matplotlib, optionally using blit for speedīackground = _from_bbox(ax.bbox) In particular, using blit to avoid redrawing the background on every frame can give you substantial speed gains (~10x): #!/usr/bin/env pythonĭef randomwalk(dims=(256, 256), n=20, sigma=5, alpha=0.95, seed=1):ĭelta = (1. If you're interested in realtime plotting, I'd recommend looking into matplotlib's animation API.
0 Comments
Leave a Reply. |