标签:图形 http 数组 tle mic tutorial graph png class
采用addplot()方法将多个图形添加到一个窗口。
首先利用numpy模块创建两个随机数组,用来作为图形绘制的数据:
import pyqtgraph as pg import numpy as np x = np.random.random(50) y = np.random.random(10) z = np.r_[x,y]
def pg_addplot(): app = pg.QtGui.QApplication([]) win = pg.GraphicsWindow(title="PyQtGraph Tutorial") p1 = win.addPlot(title=‘x曲线‘) p1.plot(x) p2 = win.addPlot(title=‘y曲线‘) p2.plot(y) app.exec_()
上图为1行2列布置,通过nextRow()更改为2行1列
def pg_addplot():
app = pg.QtGui.QApplication([])
win = pg.GraphicsWindow(title="PyQtGraph Tutorial")
p1 = win.addPlot(title=‘x曲线‘)
p1.plot(x)
win.nextRow()
p2 = win.addPlot(title=‘y曲线‘)
p2.plot(y)
app.exec_()
将多个图形放置在一个窗口内,并且占用不同列数
def pg_addplot():
app = pg.QtGui.QApplication([])
win = pg.GraphicsWindow(title="PyQtGraph Tutorial")
p1 = win.addPlot(title=‘x曲线‘)
p1.plot(x)
p2 = win.addPlot(title=‘y曲线‘)
p2.plot(y)
win.nextRow()
p3 = win.addPlot(colspan=2,title=‘z 曲线‘)
p3.plot(z)
app.exec_()
标签:图形 http 数组 tle mic tutorial graph png class
原文地址:https://www.cnblogs.com/conpi/p/12238420.html