portfantastic.blogg.se

Matplotlib scatter marker
Matplotlib scatter marker













#MATPLOTLIB SCATTER MARKER CODE#

Copy-paste this code in a new python-file, and run it. tStyle(QStyleFactory.create('Plastique')) MySrc.data_signal.emit(y) # <- Here you emit a signal! # Believe me, if you don't do this right, things # 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))

matplotlib scatter marker

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.

matplotlib scatter marker

But that is ugly IMO to loop through a DataFrame row by row and I strongly believe there is a better way.If you're interested in realtime plotting, I'd recommend looking into matplotlib's animation API. That would result in 4 plt.scatter(.) as there are 4 groups in total. Then plot them with the marker argument set with the list defined (like plt.scatter(., marker=markers). I can for loop over the DataFrame and group the entries by their group. TypeError: 'Series' objects are mutable, thus they cannot be hashed I thought plt.scatter(x=df, y=df, c=df, marker=df) For example the red entries will have marker "o" (big dot), green entries with marker "^" (upward triangle) and so on.

matplotlib scatter marker

I want the groups to have different marker styles as well.

matplotlib scatter marker

# plt.scatter(x=df, y=df, c=df, marker=df) Minimal working code import matplotlib.pyplot as pltĭf = np.random.randint(100, size=100)ĭf = np.random.randint(4, size=100)ĭf = df.apply(lambda x: colors], axis=1)ĭf = df.apply(lambda x: markers], axis=1) They are grouped by the column group and I want them to have different marker styles based on the group. I am trying to plot a scatter graph on some data with grouping.













Matplotlib scatter marker