Python pyqtgraph:在GLSurfacePlotItem对象上设置smooth=False时出现问题

Python pyqtgraph:在GLSurfacePlotItem对象上设置smooth=False时出现问题,python,python-3.x,pyqtgraph,qtgui,Python,Python 3.x,Pyqtgraph,Qtgui,我目前正在尝试使用pyqtgraph在3D中绘制一个基本颜色编码的“切片”。当我用smooth=True初始化GLSurfacePlotItem对象时,一切正常。然而,当我简单地设置smooth=False时,就会出现大量错误和警告。不幸的是,文档并没有对这个设置进行太多的解释 下面是我的示例代码。我错过了什么 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import numpy as np import matplotl

我目前正在尝试使用
pyqtgraph
在3D中绘制一个基本颜色编码的“切片”。当我用
smooth=True
初始化
GLSurfacePlotItem
对象时,一切正常。然而,当我简单地设置
smooth=False
时,就会出现大量错误和警告。不幸的是,文档并没有对这个设置进行太多的解释

下面是我的示例代码。我错过了什么

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt

from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import pyqtgraph as pg

x, y, z = 30, 20, 10
data = np.random.rand(x,y,z)

cmap = matplotlib.cm.get_cmap('jet')
norm = matplotlib.colors.PowerNorm(vmin=0.0, vmax=1.0, gamma=2.5)
m = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap)

colors = np.zeros((x,y,z,4), dtype=np.float16)
for i in range(x):
    colors[i,:,:,:] = m.to_rgba(data[i,:,:])

app = QtGui.QApplication(sys.argv)
w = gl.GLViewWidget()

zslice = gl.GLSurfacePlotItem(x=np.arange(0,x,1), y=np.arange(0,y,1), z=np.ones((x,y))*0.5, colors=colors[:,:,0,:], smooth=True, computeNormals=False)

w.addItem(zslice)
w.setGeometry(100, 10, 1280, 720)
w.show()

if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
    QtGui.QApplication.instance().exec_()
设置
smooth=False时收到的错误消息:

[13:16:04]

    |==============================>>
    |  Traceback (most recent call last):
    |    File "./test5.py", line 34, in <module>
    |      QtGui.QApplication.instance().exec_()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 179, in paintGL
    |      self.drawItemTree(useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 219, in drawItemTree
    |      self.drawItemTree(i, useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 200, in drawItemTree
    |      debug.printExc()
    |    --- exception caught here ---
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 197, in drawItemTree
    |      i.paint()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 167, in paint
    |      self.parseMeshData()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 151, in parseMeshData
    |      self.colors = md.vertexColors(indexed='faces')
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/MeshData.py", line 239, in vertexColors
    |      self._vertexColorsIndexedByFaces = self._vertexColors[self.faces()]
    |  IndexError: index 30 is out of bounds for axis 0 with size 30
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLSurfacePlotItem.GLSurfacePlotItem object at 0x7f9f0cf21410>.
[13:16:04]

    |==============================>>
    |  Traceback (most recent call last):
    |    File "./test5.py", line 34, in <module>
    |      QtGui.QApplication.instance().exec_()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 179, in paintGL
    |      self.drawItemTree(useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 219, in drawItemTree
    |      self.drawItemTree(i, useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 200, in drawItemTree
    |      debug.printExc()
    |    --- exception caught here ---
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 197, in drawItemTree
    |      i.paint()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 167, in paint
    |      self.parseMeshData()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 151, in parseMeshData
    |      self.colors = md.vertexColors(indexed='faces')
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/MeshData.py", line 239, in vertexColors
    |      self._vertexColorsIndexedByFaces = self._vertexColors[self.faces()]
    |  IndexError: index 30 is out of bounds for axis 0 with size 30
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLSurfacePlotItem.GLSurfacePlotItem object at 0x7f9f0cf21410>.
[13:16:04]

    |==============================>>
    |  Traceback (most recent call last):
    |    File "./test5.py", line 34, in <module>
    |      QtGui.QApplication.instance().exec_()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 179, in paintGL
    |      self.drawItemTree(useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 219, in drawItemTree
    |      self.drawItemTree(i, useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 200, in drawItemTree
    |      debug.printExc()
    |    --- exception caught here ---
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 197, in drawItemTree
    |      i.paint()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 167, in paint
    |      self.parseMeshData()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 151, in parseMeshData
    |      self.colors = md.vertexColors(indexed='faces')
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/MeshData.py", line 239, in vertexColors
    |      self._vertexColorsIndexedByFaces = self._vertexColors[self.faces()]
    |  IndexError: index 30 is out of bounds for axis 0 with size 30
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLSurfacePlotItem.GLSurfacePlotItem object at 0x7f9f0cf21410>.
[13:16:06]

    |==============================>>
    |  Traceback (most recent call last):
    |    File "./test5.py", line 34, in <module>
    |      QtGui.QApplication.instance().exec_()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 179, in paintGL
    |      self.drawItemTree(useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 219, in drawItemTree
    |      self.drawItemTree(i, useItemNames=useItemNames)
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 200, in drawItemTree
    |      debug.printExc()
    |    --- exception caught here ---
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/GLViewWidget.py", line 197, in drawItemTree
    |      i.paint()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 167, in paint
    |      self.parseMeshData()
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 151, in parseMeshData
    |      self.colors = md.vertexColors(indexed='faces')
    |    File "/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgraph/opengl/MeshData.py", line 239, in vertexColors
    |      self._vertexColorsIndexedByFaces = self._vertexColors[self.faces()]
    |  IndexError: index 30 is out of bounds for axis 0 with size 30
    |==============================<<
Error while drawing item <pyqtgraph.opengl.items.GLSurfacePlotItem.GLSurfacePlotItem object at 0x7f9f0cf21410>.
[13:16:04]
|==============================>>
|回溯(最近一次呼叫最后一次):
|文件“/test5.py”,第34行,在
|QtGui.QApplication.instance()
|paintGL中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第179行
|self.drawItemTree(useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第219行
|self.drawItemTree(i,useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第200行
|debug.printExc()
|---这里有个例外---
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第197行,位于drawItemTree中
|一、油漆()
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/GLMeshItem.py”,第167行,绘制
|self.parseMeshData()
|parseMeshData中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/glmeshim.py”,第151行
|self.colors=md.vertexColors(index='faces')
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/MeshData.py”,第239行,以VertexColor表示
|self.\u vertexColorsIndexedByFaces=self.\u vertexColors[self.faces()]
|索引器:索引30超出大小为30的轴0的界限
|==============================>
|回溯(最近一次呼叫最后一次):
|文件“/test5.py”,第34行,在
|QtGui.QApplication.instance()
|paintGL中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第179行
|self.drawItemTree(useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第219行
|self.drawItemTree(i,useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第200行
|debug.printExc()
|---这里有个例外---
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第197行,位于drawItemTree中
|一、油漆()
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/GLMeshItem.py”,第167行,绘制
|self.parseMeshData()
|parseMeshData中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/glmeshim.py”,第151行
|self.colors=md.vertexColors(index='faces')
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/MeshData.py”,第239行,以VertexColor表示
|self.\u vertexColorsIndexedByFaces=self.\u vertexColors[self.faces()]
|索引器:索引30超出大小为30的轴0的界限
|==============================>
|回溯(最近一次呼叫最后一次):
|文件“/test5.py”,第34行,在
|QtGui.QApplication.instance()
|paintGL中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第179行
|self.drawItemTree(useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第219行
|self.drawItemTree(i,useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第200行
|debug.printExc()
|---这里有个例外---
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第197行,位于drawItemTree中
|一、油漆()
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/GLMeshItem.py”,第167行,绘制
|self.parseMeshData()
|parseMeshData中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/items/glmeshim.py”,第151行
|self.colors=md.vertexColors(index='faces')
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/MeshData.py”,第239行,以VertexColor表示
|self.\u vertexColorsIndexedByFaces=self.\u vertexColors[self.faces()]
|索引器:索引30超出大小为30的轴0的界限
|==============================>
|回溯(最近一次呼叫最后一次):
|文件“/test5.py”,第34行,在
|QtGui.QApplication.instance()
|paintGL中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第179行
|self.drawItemTree(useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第219行
|self.drawItemTree(i,useItemNames=useItemNames)
|drawItemTree中的文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第200行
|debug.printExc()
|---这里有个例外---
|文件“/home/steve/anaconda3/lib/python3.7/site packages/pyqtgraph/opengl/GLViewWidget.py”,第197行,位于drawItemTree中
|一、油漆()
|文件“/home/steve/anaconda3/lib/python3.7/site-packages/pyqtgra