PyQtGraph Basic Realization

Posted gnops

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PyQtGraph Basic Realization相关的知识,希望对你有一定的参考价值。

Profile

The Following Picture is the result of this time‘s work. It‘s the first step used to verify the basic function of PyQtGraph.

技术分享图片

Download PyQtGraph

It‘s Always recommanded to download PyqtGraph through pip, As

 pip install pyqtgraph

If you want to speed up the download process, you can use the one provided by DouBan, use command as 

  pip install pyqtgraph -i https://pypi.douban.com/simple

Inherit pyqtgraph.GraphicLayoutWidget in QtDesigner

The basic conception of inheriting modules in QtDesigner would not be mentioned here. Please google/baidu it by your self. 

Following picture is the configuration.

技术分享图片

After using PyUIC to Create the MainWindow class,  you would have found all this widget‘s setup is updated.

self.Graphics_container = GraphicsLayoutWidget()
self.Graphics_container.setGeometry(QtCore.QRect(0, 0, 1200, 450))
self.Graphics_container.setMinimumSize(QtCore.QSize(1200, 0))
self.Graphics_container.setObjectName("Graphics_container")

 The GraphicsLayoutWidget would be imported as well

from pyqtgraph import GraphicsLayoutWidget

Add new Graph in the Widget

        plt1 = self.Graphics_container.addPlot(row=0,col=0)
        plt2 = self.Graphics_container.addPlot(row=1,col=0)
        plt3 = self.Graphics_container.addPlot(row=2,col=0)
        plt4 = self.Graphics_container.addPlot(row=3,col=0)
        plt5 = self.Graphics_container.addPlot(row=4,col=0)
        plt6 = self.Graphics_container.addPlot(row=5,col=0)        

Create Pattern of Graph

        list1 = []
        for i in range(10):
            list1.extend(np.zeros(20))
            list1.extend(np.ones(20))        

Call Pattern in the Graph

        plt1.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Red Line")
        plt2.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Green Line")
        plt3.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Blue Line")
        plt4.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Green Line")
        plt5.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Green Line")
        plt6.plot(list1,pen=pg.mkPen(color=#AA0000, width=1),name="Green Line")

pg is the pyqtGraph, which was imported as pg, through mkpen(**args) we can define the brush used in the Graph, you can use the same way add more Lines in the same plot

These is the first part of my Work, To be Continue

以上是关于PyQtGraph Basic Realization的主要内容,如果未能解决你的问题,请参考以下文章

pyqtgraph - ImportError:没有名为 pyqtgraph 的模块

pyqtgraph绘图如何使用pyqtgraph

用PyQtGraph绘制可视化数据图表

pyqtgraph绘图线条,填充和颜色

pyqtgraph绘图Qt速成课程

pyqtgraph 编译为可执行文件失败