qimage2ndarray icon indicating copy to clipboard operation
qimage2ndarray copied to clipboard

Applying different color maps to 2d array

Open vguillet opened this issue 5 years ago • 1 comments

Good afternoon,

I was wondering is it was possible to convert a 2d numpy array to a Pixmap with a colour gradient (similar to numpy's colorbar method) instead of a gray?

Thank you!

vguillet avatar May 27 '20 10:05 vguillet

This functionality is not available yet, and I am not 100% sure if it should be. The current scope of qimage2ndarray is to be able to convert from ndarrays to QImage and back, with a few helper functions allowing to load/save or scale grayvalues.

I believe the latter is where you're coming from – it may appear as if qimage2ndarray intends to do the mapping from arbitrary values to QImage as well. On the one hand, I could imagine that a simple interface with matplotlib for instance might make sense – if array2qimage would accept a cmap parameter for instance and then make use of a matplotlib colormap function. On the other hand, I hesitate a little, because I wonder if this would be feature creep? Would people then ask to also have non-MPL colormaps included to get rid of the dependency? Would people eventually require even more ways to influence the mapping?

I honestly value your and others' opinions. (And should have picked up the discussion earlier, sorry about the delay.)

hmeine avatar Apr 16 '21 07:04 hmeine