roomsbion.blogg.se

Add line to scatter plot python
Add line to scatter plot python








add line to scatter plot python

add line to scatter plot python

MySrc.data_signal.emit(y) # <- Here you emit a signal! # Believe me, if you don't do this right, things

add line to scatter plot python

# send data to your GUI in a thread-safe way. # You need to setup a signal slot mechanism, to Self.line1_t_data(np.append(self.n, self.n), np.append(self.y, self.y)) # Extends the _step() method for the TimedAnimation class. TimedAnimation._init_(self, self.fig, interval = 50, blit = True) Self.line1_head = Line2D(,, color='red', marker='o', markeredgecolor='r') 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

ADD LINE TO SCATTER PLOT PYTHON CODE

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.










Add line to scatter plot python