我有太多的相关特征(~100),导致图像分辨率低。如何提高分辨率?
sns.heatmap(Feature_corr, cbar = True, square = True, annot=False,annot_kws={'size': 15}, cmap= 'coolwarm')
在
figure
之前从matplotlib.pyplot
调用heatmap
,并通过figsize
设置图像大小,即:
import seaborn as sns
from matplotlib import pyplot
pyplot.figure(figsize=(15, 15)) # width and height in inches
sns.heatmap(Feature_corr, cbar=1, square=1, annot=0, annot_kws={'size': 15}, cmap= 'coolwarm')
使用 Matplotlib 中的图形参数可以修改轴标签的宽度、高度、字体大小和 dpi。调整这些值可能有助于您的图像分辨率。
此外,您可以使用
annot_kws={"size": 8}
中的参数 sns.heatmap()
来修改值的字体大小。
DPI表示图中每英寸的像素数。较高的 DPI 值可提高分辨率。
corr = df2.corr() #your dataframe
sns.heatmap(corr, cmap="Blues", annot=True)
未经 Matplotlib 调整的结果图像
import matplotlib.pyplot as plt
import seaborn as sns
corr = df2.corr() #your dataframe
# figsize=(6, 6) control width and height
# dpi = 600, I
plt.figure(figsize=(6, 6),
dpi = 600)
# parameter annot_kws={"size": 8} control corr values font size
sns.heatmap(corr, cmap="Blues", annot=True, annot_kws={"size": 8})
plt.tick_params(axis = 'x', labelsize = 12) # x font label size
plt.tick_params(axis = 'y', labelsize = 12) # y font label size
结果: