zoukankan      html  css  js  c++  java
  • pyqtgraph--用addplot绘制图像

     

    import pyqtgraph as pg
    import numpy as np
    
    a = np.random.random(50)
    b = np.random.random(10)
    c = np.r_[a, b]
    
    app = pg.QtGui.QApplication([])
    win = pg.GraphicsWindow(title="绘图窗口")  #创建绘图窗口
    p1 = win.addPlot(title='a曲线')  #在绘图窗口win中添加一个坐标
    p1.plot(a)  #在坐标p1中绘制a曲线
    p2 = win.addPlot(title='b曲线')
    p2.plot(b)
    p3=win.addPlot(title='z曲线')
    p3.plot(c,pen = 'b')
    #pen = 'b'   曲线颜色
    app.exec_()

    以上各图是水平分布的

    import pyqtgraph as pg
    import numpy as np
    
    a = np.random.random(50)
    b = np.random.random(10)
    c = np.r_[a, b]
    
    app = pg.QtGui.QApplication([])
    win = pg.GraphicsWindow(title="绘图窗口")  
    p1 = win.addPlot(title='a曲线')  
    p1.plot(a)  
    win.nextRow()  #在窗口win中指向下一行
    p2 = win.addPlot(title='b曲线')
    p2.plot(b)
    p3=win.addPlot(title='z曲线')
    p3.plot(c,pen = 'b')
    #pen = 'b'   
    app.exec_()

    效果图:

    以上各图的大小是一样的

    import pyqtgraph as pg
    import numpy as np
    
    a = np.random.random(50)
    b = np.random.random(10)
    c = np.r_[a, b]
    
    app = pg.QtGui.QApplication([])
    win = pg.GraphicsWindow(title="绘图窗口")  
    p1 = win.addPlot(colspan=2,title='a曲线')  
    #colspan=2    占用两列
    p1.plot(a)  
    win.nextRow()  
    p2 = win.addPlot(title='b曲线')
    p2.plot(b)
    p3=win.addPlot(title='z曲线')
    p3.plot(c,pen = 'b')
    app.exec_()

    效果图:

  • 相关阅读:
    发送信号控制 nginx
    常用技术搜索关键字
    boost helloworlld
    快速认识boost 数据类型转换
    php helloworld
    标准模板库(STL)学习指南之List容器
    c 可变参数 可变 形参 不确定 (2)
    C宏——智者的利刃,愚者的恶梦!
    boost常用库案例
    c++ 模板
  • 原文地址:https://www.cnblogs.com/liming19680104/p/13202983.html
Copyright © 2011-2022 走看看