Une visualisation bien choisie révèle des insights invisibles dans un tableau. Maîtrisez Matplotlib, Seaborn et Plotly pour raconter vos données.
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(df['mois'], df['ventes'], marker='o', color='#0891B2')
ax.set_title('Ventes mensuelles 2026')
ax.set_xlabel('Mois')
ax.set_ylabel('CA (FCFA)')
ax.grid(alpha=0.3)
plt.tight_layout()
plt.savefig('ventes.png', dpi=300)
plt.show()
fig, axes = plt.subplots(2, 2, figsize=(14, 10)) axes[0,0].hist(df['prix'], bins=30) axes[0,1].scatter(df['surface'], df['loyer']) axes[1,0].boxplot([df_a, df_b, df_c]) axes[1,1].bar(regions, totaux)
import seaborn as sns sns.set_theme(style='whitegrid') sns.scatterplot(data=df, x='surface', y='loyer', hue='quartier') sns.histplot(data=df, x='prix', kde=True) sns.boxplot(data=df, x='region', y='ventes') sns.heatmap(df.corr(numeric_only=True), annot=True, cmap='coolwarm') sns.pairplot(df[['prix', 'surface', 'chambres']])
sns.heatmap(df.corr()) en 1 ligne révèle toutes les corrélations entre vos variables numériques. Indispensable en EDA.
import plotly.express as px
fig = px.scatter(df, x='surface', y='loyer', color='quartier',
hover_data=['chambres', 'age'],
title='Loyers Yaoundé 2026')
fig.show() # zoom, hover, export PNG natifs
| Objectif | Graphique |
|---|---|
| Comparer catégories | Bar chart |
| Évolution temporelle | Line chart |
| Distribution | Histogram, boxplot |
| Corrélation 2 vars | Scatter |
| Matrice corrélation | Heatmap |
| Parts d'un tout | Pie (à éviter !) → Bar empilé |
plt.savefig('graph.png', dpi=300, bbox_inches='tight') # impression
plt.savefig('graph.svg') # vectoriel web
plt.savefig('graph.pdf') # rapport
from ydata_profiling import ProfileReport
profile = ProfileReport(df, title='Rapport EDA Ventes Cameroun')
profile.to_file('rapport.html')
# 80 pages d'analyses générées en 30 secondes
Une bonne présentation suit la règle des 4-5 slides clés :
ventes_region = df.groupby(['region', 'produit'])['ca'].sum().reset_index()
fig = px.bar(ventes_region, x='region', y='ca', color='produit',
title='CA par région et produit (2026)',
color_discrete_sequence=px.colors.qualitative.Set2)
fig.update_layout(xaxis_title='', yaxis_title='CA (FCFA)')
fig.show()