Created
August 7, 2019 07:14
-
-
Save wailashi/6ea42db5ac78f6af7a8f10a7771a13bc to your computer and use it in GitHub Desktop.
Pyqtgraph HistogramLUTWidget getLookupTable error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from pyqtgraph.Qt import QtGui, QtCore | |
import pyqtgraph as pg | |
app = QtGui.QApplication([]) | |
win = QtGui.QMainWindow() | |
win.resize(800,600) | |
win.show() | |
win.setWindowTitle('pyqtgraph example: Histogram LUT') | |
cw = QtGui.QWidget() | |
win.setCentralWidget(cw) | |
l = QtGui.QGridLayout() | |
cw.setLayout(l) | |
l.setSpacing(0) | |
v = pg.GraphicsView() | |
vb = pg.ViewBox() | |
vb.setAspectLocked() | |
v.setCentralItem(vb) | |
l.addWidget(v, 0, 0, 3, 1) | |
w = pg.HistogramLUTWidget() | |
l.addWidget(w, 0, 1) | |
data = pg.gaussianFilter(np.random.normal(size=(256, 256, 3)), (20, 20, 0)) | |
for i in range(32): | |
for j in range(32): | |
data[i*8, j*8] += .1 | |
img = pg.ImageItem(data) | |
vb.addItem(img) | |
vb.autoRange() | |
w.setImageItem(img) | |
w.gradient.colorMap().getLookupTable(mode='qcolor', alpha=True) # Works | |
w.gradient.getLookupTable(512) # Works but does not return QColors | |
w.gradient.colorMap().getLookupTable(mode='qcolor', alpha=False) # Fails | |
w.gradient.colorMap().getLookupTable(mode='qcolor') # Fails | |
## Start Qt event loop unless running in interactive mode. | |
if __name__ == '__main__': | |
import sys | |
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): | |
QtGui.QApplication.instance().exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment