๐ฅ Seaborn Heatmaps
Seaborn makes it easy to create attractive heatmaps to visualize correlation matrices or 2D data.
Mastering this concept will significantly boost your Python data science skills!
๐ป Code Example:
import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np # 1. Real-world correlation heatmap np.random.seed(42) df = pd.DataFrame({ "Python Score": np.random.randint(60, 100, 50), "AI Score" : np.random.randint(55, 100, 50), "DevOps Score": np.random.randint(50, 100, 50), "Study Hours" : np.random.randint(2, 12, 50), "Projects Done": np.random.randint(1, 10, 50), }) corr = df.corr() plt.figure(figsize=(8, 5)) sns.heatmap( corr, annot=True, fmt=".2f", cmap="coolwarm", linewidths=0.5, square=True, cbar_kws={"shrink": 0.8}, ) plt.title("Pynfinity Learner Correlation Matrix", fontsize=13, pad=12) plt.tight_layout() # 2. Distribution visualisation fig, axes = plt.subplots(1, 2, figsize=(12, 4)) sns.boxplot(data=df, ax=axes[0]) axes[0].set_title("Score Distributions (Box Plot)") sns.pairplot(df[["Python Score", "AI Score", "Study Hours"]]) plt.suptitle("Pair Plot โ Pynfinity Learners", y=1.02) plt.show()
Keep exploring and happy coding! ๐ป