Python绘图库之pyqtgraph的用法详解
SongYuLong的博客 人气:0plot
设置plot的pen属性的几种方法,通过画笔可以设置绘制图像的颜色、线宽等参数:
- pen=(255,0,0)
- pen=pg.mkPen(color=‘b’, width=5)
- pen=pg.mkPen({‘color’:‘FF0’, ‘width’: 2})
import sys import os from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * import pyqtgraph as pg import numpy as np pg.systemInfo() data = np.random.normal(size=10000) f1 = pg.plot(title='波形图1', y=data, pen=(255,0,0)) f1.setBackground('w') f2 = pg.plot(title='波形图2', y=np.random.normal(size=50), pen=pg.mkPen(color='b', width=5)) f2.setBackground('g') f3 = pg.plot(title='波形图3', y=np.random.normal(size=500),pen=pg.mkPen({'color':'FF0', 'width': 2})) f3.setBackground('b') if __name__ == "__main__": pg.QtGui.QGuiApplication.exec_()
每个plot绘制的波形图都是一个独立的应用程序窗口:
设置symbolBrush,symbolPen属性:
import sys import numpy as np import pyqtgraph as pg pg.plot(np.random.normal(size=100), pen=(255, 255, 0), symbolBrush=(0, 255, 0), symbolPen=(255, 0, 0)) if __name__ == "__main__": pg.QtGui.QGuiApplication.exec_()
image
import sys import numpy as np import pyqtgraph as pg pg.image(np.random.normal(size=(500, 500))) if __name__ == "__main__": pg.QtGui.QGuiApplication.exec_()
加载全部内容