Well, I had a similar problem and figured out how to properly set a formatter. Your example would become something like:
import numpy as np; np.random.seed(0)import seaborn as sns; sns.set()uniform_data = np.random.rand(10, 12)uniform_data = 100 * uniform_datasns.heatmap(uniform_data, cbar_kws={'format': '%.0f%%'})
So, what you have to do is to pass an old-style string formatter to add percentages to colorbar labels. Not exactly what I would name self-evident, but works...
To show only the first and last, then you add vmax
, vmin
and an extra parameter to cbar_kws
:
sns.heatmap(uniform_data, cbar_kws={'format': '%.0f%%', 'ticks': [0, 100]}, vmax=100, vmin=0)