How to add string values to x, y axes in GLAxisItem

81 views
Skip to first unread message

Jiri Ch

unread,
May 6, 2018, 3:59:46 AM5/6/18
to pyqtgraph
Hello,

I am trying to create 3D stacked bar graph using PYQTgraph library. So far I got to the point when three axis are displayed and some random bars (not stacked). I would like to proceed now with displaying string names on x and y axes (and eventually name these axis if it is possible).

Could anyone give me some hints/suggestions how to proceed? Thanks

Here is my code:

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:10, 0:10, 0:1].reshape(3,10,10).transpose(1,2,0)

size
= np.empty((10,10,3))
size
[...,0:2] = 0.4
size
[...,2] = np.random.normal(size=(10,10))
 
bg
= gl.GLBarGraphItem(pos, size)
w
.addItem(bg)
 
if __name__ == '__main__':
   
import sys
   
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
       
QtGui.QApplication.instance().exec_()


Reply all
Reply to author
Forward
0 new messages