How To Display Ticks In Plain Number For Seaborn Heatmap With Logarithmic Scale?
I am generating a heatmap using seaborn which has a logarithmic scale. How can I change the colorbar labels from scientific notation to plain number. import math from matplotlib.co
Solution 1:
seaborn
plots are wrappers around matplotlib
so I would suggest this
ax.ticklabel_format(style='plain')
Solution 2:
The following codes helped.
For the first part of the problem adding "format" in cbar_kws parameters helped. (https://stackoverflow.com/a/35419495/8881141):
import matplotlib.ticker as tkr
formatter = tkr.ScalarFormatter(useMathText=True)
formatter.set_scientific(False)
ax = sns.heatmap(corr, square=True, mask=mask, cmap=cmap_type, linewidths=.5, vmax=vmax, vmin=vmin, norm=log_norm, cbar_kws={"ticks": cbar_ticks, "format": formatter}, center=center)
For the second part, which is caused due to a bug in matplotlib, adding the following removes the minor ticks. (https://stackoverflow.com/a/65676007/11897903):
ax.collections[0].colorbar.ax.yaxis.set_ticks([], minor=True)
Post a Comment for "How To Display Ticks In Plain Number For Seaborn Heatmap With Logarithmic Scale?"