Given this heat map:
import numpy as np; np.random.seed(0)
import seaborn as sns; sns.set()
uniform_data = np.random.rand(10, 12)
ax = sns.heatmap(uniform_data)
How would I go about making the color bar values display in percent format? Also, what if I just wanted to show the first and last values on the color bar?
Thanks in advance!
You need to be able to access the colorbar object. It might be buried in the figure object somewhere, but I couldn't find it, so the easy thing to do is just to make it yourself:
iterating on the solution of @mwaskom, without creating the colorbar yourself:
Well, I had a similar problem and figured out how to properly set a formatter. Your example would become something like:
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 tocbar_kws
: