pyqtgraph设施到pcolor情节llike matplotlib

时间:2016-08-11 22:08:11

标签: python matplotlib pyqtgraph

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分: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()