【发布时间】:2018-11-11 17:43:17
【问题描述】:
我的目标是创建堆叠的 3d 条形图,为此,我正在尝试从 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)本身没有设置颜色的方法。
任何提示如何进行?
【问题讨论】:
标签: python python-3.x pyqtgraph