小编Chr*_*ich的帖子

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

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

\n\n

这是我的代码:

\n\n
sns.set(style="white")\n# Compute the correlation matrix\ncorr = data.corr()\n\n# Generate a mask for the upper triangle\nmask = np.zeros_like(corr, dtype=np.bool)\nmask[np.triu_indices_from(mask)] = True\n\n# Set up the matplotlib figure\nf, ax = plt.subplots(figsize=(11, 9))\n\n# Generate a custom diverging colormap\ncmap = sns.diverging_palette(220, 10, as_cmap=True)\n\n# Draw the heatmap with the mask and correct aspect ratio\nsns.heatmap(corr, mask=mask, cmap=cmap, vmax=1, vmin=-1, center=0,\n        square=True, linewidths=1, cbar_kws={"shrink": .5})\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n

部分结果

\n\n

这是丢失的数据列的片段

\n\n

缺少列的片段

\n\n

正如您所看到的,问题是我缺少 CIVIST_D、F、L,并且我无法解决该问题。

\n\n

亲切的问候\n基督徒

\n

python heatmap correlation seaborn

6
推荐指数
2
解决办法
8815
查看次数

标签 统计

correlation ×1

heatmap ×1

python ×1

seaborn ×1