I have the following Python code to create a heatmap using the Seaborn package:
f, ax = plt.subplots(figsize=(21,5))
heatmap = sns.heatmap(significantBig5[basic].as_matrix().T,mask=labelsDf.T,
annot=False,fmt='.2f',yticklabels=basic_labels,linewidths=0.5,square=True,
xticklabels=traits)
plt.xticks(rotation=70)
This creates the following heatmap:
I would like to format this heatmap so that the colorbar on the right side is shorter. Is there a way to do this?
You can also use the extra keyword arguments for the sns heatmap colorbar the cbar_kws. They modify the settings for the matplotlib colorbar documented here
Using the code of @Serenity with the shrinkage keyword we get this:
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pylab as plt
arr = np.random.random((1,9))
df = pd.DataFrame(arr)
sns.heatmap(arr,cbar=True,cbar_kws={"shrink": .82})
plt.show()