Python绘图库之pyqtgraph的用法详解

plot

设置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绘制的波形图都是一个独立的应用程序窗口:

Python绘图库之pyqtgraph的用法详解_第1张图片

Python绘图库之pyqtgraph的用法详解_第2张图片

Python绘图库之pyqtgraph的用法详解_第3张图片

设置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_()

Python绘图库之pyqtgraph的用法详解_第4张图片

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_()

Python绘图库之pyqtgraph的用法详解_第5张图片

到此这篇关于Python绘图库之pyqtgraph的用法详解的文章就介绍到这了,更多相关Python绘图库pyqtgraph内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(Python绘图库之pyqtgraph的用法详解)