[Python] Is there a way I can show the values of the correlation coefficient on my heatmap?

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    I was wondering if anyone could help me with my codes. I would like to display the actual correlation coefficient values on each squares in my plot. My code below does not seem to do that.Any ideas please?

    My codes:

    full_cor = df_no_actual_SM.corr()

    # Plot correlation heatmap
    mask = np.triu(np.ones_like(full_cor, dtype=bool))


    #plt.figure(figsize=(20, 20))
    sns.set(font_scale=1.5)

    fig, ax = plt.subplots(figsize=(20, 20))
    ax.patch.set_facecolor('none')

    sns.heatmap(full_cor, annot=True, annot_kws={"size": 1, "color": "k"}, mask=mask, cmap='Greys', cbar=True, square=True, cbar_kws={"shrink": 0.7}, ax = ax)
    ax.set_title('', fontsize = 20)
    ax.tick_params(axis='x', labelsize=24, rotation=45)
    ax.tick_params(axis='y', labelsize=24, rotation=45)
    #plt.savefig("Corr_plot_R80_Nov18.png")
    plt.tight_layout()
    plt.show()

    Continue reading...

Compartilhe esta Página