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繪制的波形圖都是一個獨立的應用程序窗口:

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

到此這篇關於Python繪圖庫之pyqtgraph的用法詳解的文章就介紹到這瞭,更多相關Python繪圖庫pyqtgraph內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: