Allow menu selection of ColorMap(s)#2779
Conversation
bcac0ff to
3129baf
Compare
|
As there is too much code overlap between When so disabled, the |
a54d444 to
3778211
Compare
|
To make the levels-only mode closer in behavior to Some warts:
|
|
An example of usage. import numpy as np
import pyqtgraph as pg
pg.setConfigOption('useNumba', False)
rng = np.random.default_rng()
data = rng.rayleigh(size=(10240, 6144)).astype(np.float32)
pg.mkQApp()
glw = pg.GraphicsLayoutWidget()
glw.show()
imgitem = pg.ImageItem(axisOrder='row-major')
plot = glw.addPlot()
plot.addItem(imgitem)
hist = pg.HistogramLUTItem(image=imgitem, useColorMaps=True)
glw.addItem(hist)
# hist.gradient.setColorMap("viridis")
imgitem.setImage(data)
pg.exec()
print(imgitem.qimage.format()) |
|
UPDATE: to reduce the scope of this PR,
import numpy as np
import pyqtgraph as pg
from pyqtgraph.graphicsItems.ColorMapDisplay import ColorMapDisplayItem
rng = np.random.default_rng()
data = rng.random(size=(256,256), dtype=np.float32)
pg.mkQApp()
glw = pg.GraphicsLayoutWidget()
glw.show()
imgitem = pg.ImageItem(image=data, axisOrder='row-major')
plot = glw.addPlot()
plot.addItem(imgitem)
cmdisp1 = ColorMapDisplayItem(orientation='vertical')
cmdisp2 = ColorMapDisplayItem(orientation='horizontal')
glw.addItem(cmdisp1)
glw.nextRow()
glw.addItem(cmdisp2)
cmdisp1.sigColorMapChanged.connect(imgitem.setColorMap)
cmdisp2.sigColorMapChanged.connect(imgitem.setColorMap)
pg.exec() |
f3dd7e7 to
e1703dd
Compare
|
This is how the example in #2779 (comment) looks now |
c61b9f5 to
a65dc12
Compare
|
An alternative to replacing Advantages:
Disadvantages (due to
Other differences:
|
|
As The proof of concept new colormap parameter is thus renamed to A decision should be made whether the old |
|
The original There is actually an If this is not a desirable change, it can be reverted. |
2ed4240 to
b74f72d
Compare
|
Thanks for this PR @pijyoi sorry I let this sit idle for so long... this diff LGTM, ...having the gradient colormaps be different from the regular color maps always seemed less than...ideal. Merging! |

UPDATE: the scope of this PR has evolved from the original
HistogramLevelsItem(analog toHistogramLUTItem) toColorMapDisplayItem(analog toGradientEditorItem). The contents of this comment should be considered outdated.HistogramLevelsItemis a simplified version ofHistogramLUTItem.Differences:
ColorMapproperty fromImageItem. Expects thatColorMaphas been set.GradientEditorItem. Colormaps are non-editable.The
NonUniformImageexample has been modified to useHistogramLevelsItem. It was originally usingHistogramLUTItembut had been changed toColorBarItemto avoid the monkey patch of color presets. Changing it to useHistogramLevelsItemmakes the example closer to its original look.