Personnaliser des heatmaps
Seaborn offre plusieurs options de personnalisation supplémentaires pour améliorer le rendu d'une heatmap. Dans cet exercice, nous continuons d'utiliser les données de The Daily Show stockées dans la variable df, mais nous allons en personnaliser l'affichage.
Cet exercice fait partie du cours
<cours>Visualisation de données intermédiaire avec Seaborn</cours>Instructions de l’exercice
- Créez une table de contingence entre
GroupetYEAR - Créez une heatmap des données en utilisant la palette
BuGn - Désactivez la
cbaret augmentezlinewidthà 0,3
Exercice interactif pratique
Essayez cet exercice en complétant ce code d’exemple.
# Create the crosstab DataFrame
pd_crosstab = pd.crosstab(df["Group"], df["____"])
# Plot a heatmap of the table with no color bar and using the BuGn palette
sns.heatmap(pd_crosstab, cbar=____, cmap="____", linewidths=____)
# Rotate tick marks for visibility
plt.yticks(rotation=0)
plt.xticks(rotation=90)
#Show the plot
plt.show()
plt.clf()