如何使 seaborn.heatmap 变大(正常大小)?
How to make seaborn.heatmap larger (normal size)?
我在 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');
得到如下图
即正方形显得小得令人无法接受。
如何让它们变大?
在使用heatmap()
之前,调用matplotlib.pyplot.figure()
时使用figsize
参数来设置图形的大小。例如:
pyplot.figure(figsize=(10, 16))
sns.heatmap(...)
传递给 figsize
的元组的两个元素是图形的所需宽度和高度(以英寸为单位)。然后,当您制作热图时,它会拉伸以填充给定大小的可用 space。您可能需要做一些实验才能确定最佳尺寸。
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 9))
sns.heatmap(df)
我在 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');
得到如下图
即正方形显得小得令人无法接受。
如何让它们变大?
在使用heatmap()
之前,调用matplotlib.pyplot.figure()
时使用figsize
参数来设置图形的大小。例如:
pyplot.figure(figsize=(10, 16))
sns.heatmap(...)
传递给 figsize
的元组的两个元素是图形的所需宽度和高度(以英寸为单位)。然后,当您制作热图时,它会拉伸以填充给定大小的可用 space。您可能需要做一些实验才能确定最佳尺寸。
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 9))
sns.heatmap(df)