[Python] Color heatmap based on condition

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have a datframe which I have used to create a heatmap using sns.

    ax = sns.heatmap(df, annot=True, vmax=0.1, cmap="YlGnBu", vmax=0.005,cbar=False)


    I wish to color the heatmap if a condition is made; e.g. I wish the squares where the value is <0.1 to be coloured green and all others to be grey. How can I do this? I suspect this is using vmax but am uncertain how it actually works?

    Continue reading...

Compartilhe esta Página