How to make seaborn.heatmap larger (normal size)?

Dims picture Dims · Jan 7, 2017 · Viewed 26k times · Source

I displayed plot with the following command in jupyter notebook:

sns.heatmap(pcts, annot=True, linewidth=.1, vmax=99, fmt='.1f', cmap='YlOrRd', square=True, cbar=False)
plt.yticks(list(reversed(range(len(indices)))), ['Index '+str(x) for x in indices], rotation='horizontal')
plt.title('Percentile ranks of\nsamples\' category spending');

and got the following picture

heatmap with squares too small

i.e. squares appear unacceptably small.

How can I make them larger?

Answer

David Z picture David Z · Jan 7, 2017

Before using heatmap(), call matplotlib.pyplot.figure() with the figsize parameter to set the size of the figure. For example:

pyplot.figure(figsize=(10, 16))
sns.heatmap(...)

The two elements of the tuple passed to figsize are the desired width and height of the figure in inches. Then when you make the heatmap, it will stretch to fill the available space given that size. You may have to do a bit of experimentation to determine what size looks best.