gpt4 book ai didi

python - Jupiter Python seaborn 热图未显示所有相关性

转载 作者:行者123 更新时间:2023-12-03 23:16:35 25 4
gpt4 key购买 nike

我的相关性热图有一些问题。它没有显示我感兴趣的所有列。

这是我的代码:

sns.set(style="white")
# Compute the correlation matrix
corr = data.corr()

# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True

# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))

# Generate a custom diverging colormap
cmap = sns.diverging_palette(220, 10, as_cmap=True)

# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=1, vmin=-1, center=0,
square=True, linewidths=1, cbar_kws={"shrink": .5})

代码基于: https://seaborn.pydata.org/examples/many_pairwise_correlations.html

Part of the result

这是丢失的数据列的片段

Snip of the columns missing

如您所见,问题是我缺少 CIVIST_D、F、L
我无法解决它。

亲切的问候
基督教

最佳答案

尝试增加绘图的大小。
它对我有用

corr=df.corr()
plt.subplots(figsize=(20,15))
sns.heatmap(corr)

关于python - Jupiter Python seaborn 热图未显示所有相关性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49896067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com