pyqtgraph 工具 pcolor plot 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'})
我查看了文档 here 来构建该示例。
你也可以试试:
import pyqtgraph.examples
pyqtgraph.examples.run()
查看更多示例
pyqtgraph支持画图。您可以查看 pyqtgraph 示例下的 imageAnalysis.py, ImageItem.py and 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()
是否有可能像 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'})
我查看了文档 here 来构建该示例。
你也可以试试:
import pyqtgraph.examples
pyqtgraph.examples.run()
查看更多示例
pyqtgraph支持画图。您可以查看 pyqtgraph 示例下的 imageAnalysis.py, ImageItem.py and 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()