(编辑:jimmy 日期: 2024/12/26 浏览:2)
PyQtGraph是纯Python的,只是它底层调用的是PyQt,也就是Qt的Python封装,底层用C/C++语言开发的库,它是在PyQt的基础上开发的可视化控件,相较于老牌的绘制库,PyQtGraph在绘图速度上特别突出,保证绘图的美观性以及强大功能前提下,能够极高的效率去绘制图形,下面一起来详细了解下使用技巧吧。
pyqtgraph库安装:
pip install --user pyqtgraph
更快安装方式:
pip3.8 install -i https://mirrors.aliyun.com/pypi/simple
导入方式:
import pyqtgraph as pg
自带实例模块:
python -m pyqtgraph.examples
绘制折线图:
from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg from pyqtgraph.widgets.RemoteGraphicsView import RemoteGraphicsView app = pg.mkQApp() v = RemoteGraphicsView(debug=False) v.show() v.setWindowTitle('单1的折线图') plt = v.pg.PlotItem() v.setCentralItem(plt) y1=[1,4,2,3,6,2,3,4,2,3] plt.plot(y1, pen='g') QtGui.QApplication.instance().exec_()
效果展示: