我的目标是创建堆叠的三维条形图,为此,我尝试从PYQTgraph库更改GlBarGraphItem的颜色。在
这是我的代码:
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import numpy as np
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.opts['distance'] = 100
w.showMaximized()
w.setWindowTitle('pyqtgraph example: GLViewWidget')
ax = gl.GLAxisItem()
ax.setSize(20,20,20)
w.addItem(ax)
pos = np.mgrid[0:1,0:1,0:1].reshape(3,1,1).transpose(1,2,0)
size = np.empty((1,1,3))
size[...,0:2] = 1
size[...,2] = 5
bg = gl.GLBarGraphItem(pos, size)
##bg.setColor(1., 1., 1., 1.)
w.addItem(bg)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
我尝试使用.setColor()方法,但没有成功,我相信对象(GlBarGraphItem)本身没有设置颜色的方法。在
有什么进展的提示吗?在
如果修订了
GLMeshItem
paint()
方法的code:因此,
^{pr2}$setColor()
函数需要一个QColor
或一个由4个元素组成的元组,因此您可以使用以下方法:相关问题 更多 >
编程相关推荐