首页 > 其他 > 详细

PyQtGraph Basic Realization

时间:2018-12-24 14:20:14      阅读:213      评论:0      收藏:0      [点我收藏+]

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

原文:https://www.cnblogs.com/GNOPS/p/10168242.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!