pyqtgraph embedded pyqt

Stumbled on a giant cow artificial intelligence course, could not help but share to everyone. Tutorial is not only a zero-based, user-friendly, and very humorous, like watching a fiction! I think too much bad, so to others. Tutorial links: https://www.cbedai.net/qtlyx       

 

Recently made a thing, began with pyqt, think about this before use, have been for several years.

pyqt which drawing is very troublesome thing, matplotlib is said to refresh a lot of trouble? Anyway pyqtgraph and pyqt is a, well compatible, and can be perfectly embedded.

Embed the way is also very simple.

1:

In the above plus a first ui Layout, such verticalLayout

The red it is.

2:

import pyqtgraph as pg

Then init function of the window,

self.plot = pg.PlotWidget(enableAutoRange=True)
self.ui.verticalLayout.addWidget(self.plot)
self.curve = self.plot.plot()

This happen, we put a drawing of the object bound to the verticalLayout up.

3:

When we want to draw something of it, pass parameters directly on it, or np general transfer array series of pandas will do,

self.curve.setData(data)

4:

If this thing is also updated, such as a second refresh time, then clear it before drawing.

self.curve.clear()

 

 

Published 205 original articles · won praise 236 · views 980 000 +

Guess you like

Origin blog.csdn.net/qtlyx/article/details/96893500