【发布时间】:2016-12-18 19:30:04
【问题描述】:
是否有可能在 pyqtplot 中绘制 pcolor,就像 matplotlib 可以的那样?
有什么好的例子吗?
我们如何将轴添加到 pyqtgraph 图中?
【问题讨论】:
标签: python matplotlib pyqtgraph
是否有可能在 pyqtplot 中绘制 pcolor,就像 matplotlib 可以的那样?
有什么好的例子吗?
我们如何将轴添加到 pyqtgraph 图中?
【问题讨论】:
标签: python matplotlib pyqtgraph
pyqtgraph 支持绘制图像。您可以在 pyqtgraph 示例下查看 imageAnalysis.py、ImageItem.py 和 ImageView.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()
【讨论】:
试试这个开始:
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()
查看更多示例
【讨论】: