Making Log2 Scaled Heatmap In Matplotlib
I want to plot a heatmap of fold changes in matplotlib, where the colors are plotted on a log2 scale, and customize which ticks are shown in the colorbar. I tried the following: i
Solution 1:
You could set the locator
of the colorbar
object to a LogLocator
with a base of 2. You then need to call p.update_ticks()
.
plt.pcolormesh(mat, cmap=cmap, norm=SymLogNorm(linthresh=0.01, vmin=1/50., vmax=50.))
p = plt.colorbar()
p.locator=ticker.LogLocator(base=2)
p.update_ticks()
Post a Comment for "Making Log2 Scaled Heatmap In Matplotlib"