当前位置: 移动技术网 > IT编程>脚本编程>Python > PyQtGraph Basic Realization

PyQtGraph Basic Realization

2018年12月25日  | 移动技术网IT编程  | 我要评论

彭雪枫纵横江淮,诱夫:囧妃桃花多,重生一天才狂女

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网