Search code examples
pythonmatplotlibimage-processingtiff

How to define a No Data / transparent value in a Matplotlib TIFF plot?


I have a numpy array as a result from an image transformation. In the method I wrote for the image transformation the No Data value is 0 (I can change this if needed). I want to display this result with Matplotlib but offcourse the color scale stretches to the 0. Is there a way to ignore the 0 value in the visualization, make it transparent, define it as a No Data value etc. so the colorscale is stretched to the relevant values?

EDIT: Just setting the vmin=1 doesn't work all the other values are around 4000, so I can't set a fixed minimum value. And I'll need all the contrast I can get.


Solution

  • I solved this by instead of creating a numpy array of zeros at which I filled in with values cell by cell, creating a numpy array of NaN's.