Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 205
Dims Avatar asked Jan 07 '17 09:01

Dims


People also ask

How do I change font size in Seaborn heatmap?

Create a dataframe using Pandas data frame. Create a heatmap using heatmap() method. To adjust the font size in Seaborn heatmap, change the fontsize value. To display the figure, use show() method.

How do I reduce the size of the heatmap in Python?

The font size of the annotations is set by default, although it can be altered using the annot kws parameter of the heatmap() method. The annot kws is a dictionary-type option that requires a value for the size key. The size of the annotations is determined by the value assigned to this key.

Which command is used for drawing heatmap in Seaborn?

Heatmaps in Seaborn can be plotted by using the seaborn. heatmap() function.


1 Answers

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.

like image 95
David Z Avatar answered Sep 25 '22 05:09

David Z