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

不羁的心 提交于 2019-12-05 18:26:58

问题


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

i.e. squares appear unacceptably small.

How can I make them larger?


回答1:


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.




回答2:


import matplotlib.pyplot as plt

plt.figure(figsize=(12, 9))

sns.heatmap(df)


来源:https://stackoverflow.com/questions/41519991/how-to-make-seaborn-heatmap-larger-normal-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!