I have data that is in the range -70,0 that I display using imshow() and would like to use a non-linear colorbar to represent the data as I have paterns both in the -70,-60
This is what I managed to do:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import PowerNorm
sample_data=(np.ones((20,20))*np.linspace(0,1,20)**3)*70-70
plt.figure()
im = plt.imshow(sample_data+70, norm=PowerNorm(gamma=0.5))
cbar = plt.colorbar(orientation='horizontal')
cbar.ax.set_xticklabels(np.arange(-70, 0, 8))
plt.show()
You can change the gamma
.
However, this kind of visualization is not recommended, see: http://matplotlib.org/users/colormapnorms.html
under "Power-law" -> "Note"