2

I spent few hours on this but can't find solution.

I have 2D array of data and I want to plot it as heatmap using imshow() function. How can I achieve effect like this? I mean nonlineary distributed colors on colorbar to get better contrast.

I found this, but don't know how to apply it to imshow().

enter image description here

user31027
  • 345
  • 1
  • 3
  • 18
  • Check this out: http://stackoverflow.com/questions/14391959/heatmap-in-matplotlib-with-pcolor Basically after you get that 2D array of data you scale it to a color array and print in tiles. – Fma Aug 09 '16 at 12:34

1 Answers1

1

Use the norm parameter:

plt.imshow(your_data, cmap='afmhot_r', norm=colors.PowerNorm(gamma=0.2))

Read more: http://matplotlib.org/users/colormapnorms.html

user31027
  • 345
  • 1
  • 3
  • 18
  • For completeness: In order to use colors.PowerNorm(gamma=0.2) you must import the colors module: from matplotlib import colors – sist Oct 21 '20 at 14:58