pyqtgraph--用addplot绘制图像
import pyqtgraph as pg import numpy as np a = np.random.random(50) b = np.random.random(10) c = np.r_[a, b] app = pg.QtGui.QApplication([]) win = pg.GraphicsWindow(title="绘图窗口") #创建绘图窗口 p1 = win.addPlot(title='a曲线') #在绘图窗口win中添加一个坐标 p1.plot(a) #在坐标p1中绘制a曲线 p2 = win.addPlot(title='b曲线') p2.plot(b) p3=win.addPlot(title='z曲线') p3.plot(c,pen = 'b') #pen = 'b' 曲线颜色 app.exec_()
以上各图是水平分布的
import pyqtgraph as pg import numpy as np a = np.random.random(50) b = np.random.random(10) c = np.r_[a, b] app = pg.QtGui.QApplication([]) win = pg.GraphicsWindow(title="绘图窗口") p1 = win.addPlot(title='a曲线') p1.plot(a) win.nextRow() #在窗口win中指向下一行 p2 = win.addPlot(title='b曲线') p2.plot(b) p3=win.addPlot(title='z曲线') p3.plot(c,pen = 'b') #pen = 'b' app.exec_()
效果图:
以上各图的大小是一样的
import pyqtgraph as pg import numpy as np a = np.random.random(50) b = np.random.random(10) c = np.r_[a, b] app = pg.QtGui.QApplication([]) win = pg.GraphicsWindow(title="绘图窗口") p1 = win.addPlot(colspan=2,title='a曲线') #colspan=2 占用两列 p1.plot(a) win.nextRow() p2 = win.addPlot(title='b曲线') p2.plot(b) p3=win.addPlot(title='z曲线') p3.plot(c,pen = 'b') app.exec_()
效果图: