pyqtgraph设施到pcolor情节llike matplotlib

问题描述 投票:0回答:2

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

python matplotlib pyqtgraph
2个回答
0
投票

试试这个开始吧:

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


0
投票

支持在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()
© www.soinside.com 2019 - 2024. All rights reserved.