Skip to content
Advertisement

matplotlib.pyplot.clim counterpart in pyqtgraph

I want to apply a colormap (“hot”) only to a certain range of values of an image. I already know this functionality from matplotlib.pyplot.clim where you have to specify a minimum and a maximum value for the scaling. As I understood it, you should use setLevels([min,max]) for this. I have included a minimal example which shows that both representations are unfortunately not equivalent.

JavaScript

Do you know a way how I can get the same representation in pyqtgraph as with clim in matplotlib? The first image shows the result using matplotlib and the second shows the result using pyqtgraph. enter image description here enter image description here

Advertisement

Answer

This question made its way to the pyqtgraph issue tracker here: https://github.com/pyqtgraph/pyqtgraph/pull/1985#issuecomment-932223288

Here is some code to generate identical results between the two libraries

JavaScript

The poster of this code in the issue tracker noted that the “overflow” values seem to render to white in matplotlib, and black to pyqtgraph. In addition, the pyqtgraph image is rotated 90 degrees left since the axis order is not set and the y-axis is likely reversed.

to get the right rotation orientation, the code has two lines of note

JavaScript

and

JavaScript

Hopefully this helps!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement