【问题标题】:pyqtgraph facilities to pcolor plot llike matplotlibpyqtgraph 工具 pcolor plot 就像 matplotlib
【发布时间】:2016-12-18 19:30:04
【问题描述】:

是否有可能在 pyqtplot 中绘制 pcolor,就像 matplotlib 可以的那样? 有什么好的例子吗?
我们如何将轴添加到 pyqtgraph 图中?

【问题讨论】:

    标签: python matplotlib pyqtgraph


    【解决方案1】:

    pyqtgraph 支持绘制图像。您可以在 pyqtgraph 示例下查看 imageAnalysis.pyImageItem.pyImageView.py 示例。

    ImageItem 的文档是here

    这是一个简单的示例函数:

    def plot_image(data):
        """
        Plot array as an image.
        :param data: 2-D array
        """
        pl = pg.plot()
        image = pg.ImageItem()
    
        pl.addItem(image)
    
        hist = pg.HistogramLUTItem()
        # Contrast/color control
        hist.setImageItem(image)
        # pl.addItem(hist)
    
        image.setImage(data)
        pos = np.array([0., 1., 0.5, 0.25, 0.75])
        color = np.array([[0, 0, 255, 255], [255, 0, 0, 255], [0, 255, 0, 255], (0, 255, 255, 255), (255, 255, 0, 255)],
                     dtype=np.ubyte)
        cmap = pg.ColorMap(pos, color)
        lut = cmap.getLookupTable(0.0, 1.0, 256)
        image.setLookupTable(lut)
    
        hist.gradient.setColorMap(cmap)
        pl.autoRange()
    

    【讨论】:

      【解决方案2】:

      试试这个开始:

      import pyqtgraph as pg 
      x = [1, 2, 3, 4, 5]
      y = [1, 4, 9, 16, 25]
      pg.plot(x, y, title="Simple Example", labels={'left': 'Here is the y-axis', 'bottom': 'Here is the x-axis'})
      

      我查看了文档 here 来构建该示例。

      你也可以试试:

      import pyqtgraph.examples
      pyqtgraph.examples.run()
      

      查看更多示例

      另见this google groups question

      【讨论】:

      • 我在提到的 google 组中搜索了许多好的功能。它有很多功能符合我的问题。谢谢
      猜你喜欢
      • 1970-01-01
      • 2020-01-30
      • 2019-04-28
      • 1970-01-01
      • 2015-01-21
      • 2015-01-20
      • 1970-01-01
      • 2013-04-06
      相关资源
      最近更新 更多