简体   繁体   中英

pyqtgraph facilities to pcolor plot llike matplotlib

Is there any possibility to plot pcolor in pyqtplot, like the ones matplotlib can ? and Is there any good example ?
How we can add axis to pyqtgraph plot?

Try this to get started:

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

I looked at the documentation here to construct that example.

You can also try:

import pyqtgraph.examples
pyqtgraph.examples.run()

to see more examples

Also see this google groups question .

There is a support of plotting Image in pyqtgraph. You can checkout the imageAnalysis.py , ImageItem.py and ImageView.py examples under pyqtgraph examples.

The documentation for ImageItem is here

Here is the simple example function:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM