簡體   English   中英

pyqtgraph工具來pcolor繪制llike matplotlib

[英]pyqtgraph facilities to pcolor plot llike matplotlib

是否有可能像matplotlib一樣在pyqtplot中繪制pcolor? 有沒有很好的例子?
如何將軸添加到pyqtgraph圖?

試試這個開始:

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'})

我查看了此處的文檔以構造該示例。

您也可以嘗試:

import pyqtgraph.examples
pyqtgraph.examples.run()

看更多例子

另請參閱此Google網上論壇問題

支持在pyqtgraph中繪制Image。 您可以在pyqtgraph示例下簽出imageAnalysis.pyImageItem.pyImageView.py示例。

ImageItem的文檔在這里

這是簡單的示例函數:

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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM