Discussion:
[pyqtgraph] Absolute colormaps
Alessandro Tontini
2018-12-10 16:09:22 UTC
Permalink
Hi all,

I am struggling to find a way to obtain absolute colormaps with pyqtgraph.
The code snippet below is what I am using to define my colormap:


c_pos = np.array([31*0.0, 31*0.25, 31*0.75, 31*1.0])
c_color = np.array([[0, 0, 0, 255], [255, 0, 0, 255], [255, 255, 0, 255], [255, 255, 255, 255]], dtype=np.ubyte)
c_map = pg.ColorMap(c_pos, c_color)
self.c_lut = c_map.getLookupTable(0.0, 31*1.0, 31)


My input data are integers ranging from 0 up to 31.

What I am trying to obtain is a uniform colormap with 0=black and 31=white,
with shades from red to yellow in the middle.

The problem is that, if my input values are for example from 0 to 15
(instead from 0 to 31), pyqtgraph makes the resulting colormap "relative",
i.e. I have black for 0 up to white for 15.

Is there any way to define an absolute color map?

Thank you in advance
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/a1fe3e5a-6e1a-4415-ae07-4c92f04b9edf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Patrick
2018-12-11 02:03:54 UTC
Permalink
Hi,

It looks like your colormap would be working fine (except shouldn't you be
requesting 32 points not 31 in getLookupTable?). Do you mean when you
display image data using that colormap, then the range is scaled to the
minimum/maximum of the image data? If that's the case then there are
options for ImageItem/setImage to control that
(http://www.pyqtgraph.org/documentation/graphicsItems/imageitem.html#pyqtgraph.ImageItem.setImage).
Try passing in "lut=self.c_lut, levels=(0, 31)" options.

Patrick
Post by Alessandro Tontini
Hi all,
I am struggling to find a way to obtain absolute colormaps with pyqtgraph.
c_pos = np.array([31*0.0, 31*0.25, 31*0.75, 31*1.0])
c_color = np.array([[0, 0, 0, 255], [255, 0, 0, 255], [255, 255, 0, 255], [255, 255, 255, 255]], dtype=np.ubyte)
c_map = pg.ColorMap(c_pos, c_color)
self.c_lut = c_map.getLookupTable(0.0, 31*1.0, 31)
My input data are integers ranging from 0 up to 31.
What I am trying to obtain is a uniform colormap with 0=black and
31=white, with shades from red to yellow in the middle.
The problem is that, if my input values are for example from 0 to 15
(instead from 0 to 31), pyqtgraph makes the resulting colormap "relative",
i.e. I have black for 0 up to white for 15.
Is there any way to define an absolute color map?
Thank you in advance
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/0cefe978-3fd5-47dd-bc88-81fba239f783%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...