Python 如何在Streamlight中显示热图颜色相关图

Python 如何在Streamlight中显示热图颜色相关图,python,heatmap,correlation,streamlit,Python,Heatmap,Correlation,Streamlit,我正在尝试使用Streamlight进行可视化。我的其中一个内容是这样的关联: 但我希望它有像热图图一样的颜色 这是我的相关代码 df_col = pd.concat([df5, df6,df7,df8,df9], axis=1) df5.columns = ['month', 'price_kcl', 'change_kcl'] df6.columns = ['month_fosfat', 'price_fosfat', 'change_fosfat'] df7.col

我正在尝试使用Streamlight进行可视化。我的其中一个内容是这样的关联: 但我希望它有像热图图一样的颜色

这是我的相关代码

df_col = pd.concat([df5, df6,df7,df8,df9], axis=1)
    df5.columns = ['month', 'price_kcl', 'change_kcl']
    df6.columns = ['month_fosfat', 'price_fosfat', 'change_fosfat']
    df7.columns = ['month_bb', 'price_bara', 'change_bb']
    df8.columns = ['month_urea', 'price_urea', 'change_urea']
    df9.columns = ['month_npk', 'price_npk', 'change_npk']
    df_col = pd.concat([df5, df6,df7,df8,df9], axis=1)
    df5.columns = ['month', 'price_kcl', 'change_kcl']
    df6.columns = ['month_fosfat', 'price_fosfat', 'change_fosfat']
    df7.columns = ['month_bb', 'price_bara', 'change_bb']
    df8.columns = ['month_urea', 'price_urea', 'change_urea']
    df9.columns = ['month_npk', 'price_npk', 'change_npk']
    df_col = df_col.set_index('month')
    df_corr = df_col.corr()
    st.write(df_corr)
    plt.matshow(df_col.corr())

提前谢谢你

您可以在Streamlight中编写Matplotlib图形。您只需稍微修改代码:

导入seaborn作为sns
将matplotlib.pyplot作为plt导入
图,ax=plt.子批次()
sns.heatmap(df_col.corr(),ax=ax)
圣莱特(图)

您可以在Streamlight中编写Matplotlib图形。您只需稍微修改代码:

导入seaborn作为sns
将matplotlib.pyplot作为plt导入
图,ax=plt.子批次()
sns.heatmap(df_col.corr(),ax=ax)
圣莱特(图)

谢谢!但是我得到了这个错误“corr()得到了一个意外的关键字参数'ax'”这是什么意思?对不起,我忘记了热图。现在我更新了答案谢谢!但是我得到了这个错误“corr()得到了一个意外的关键字参数'ax'”这是什么意思?对不起,我忘记了热图。现在我更新了答案