Chr*_*ich 6 python heatmap correlation seaborn
我的相关性热图遇到一些问题。它没有显示我感兴趣的所有列。
\n\n这是我的代码:
\n\nsns.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})\nRun 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小智 6
尝试增加绘图的大小。这对我有用
corr=df.corr()
plt.subplots(figsize=(20,15))
sns.heatmap(corr)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8815 次 |
| 最近记录: |