๐ Matplotlib Plotting
Matplotlib is the grandfather of Python visualization libraries. It gives you control over every aspect of a figure.
Mastering this concept will significantly boost your Python data science skills!
๐ป Code Example:
import matplotlib.pyplot as plt import numpy as np fig, axes = plt.subplots(2, 2, figsize=(12, 8)) fig.suptitle("Pynfinity Data Dashboard", fontsize=14, fontweight="bold") # Panel 1 โ Line chart x = np.linspace(0, 10, 100) axes[0,0].plot(x, np.sin(x), label="sin(x)", color="royalblue") axes[0,0].plot(x, np.cos(x), label="cos(x)", color="tomato") axes[0,0].set_title("Trig Functions"); axes[0,0].legend() # Panel 2 โ Bar chart courses = ["Python", "AI", "DevOps", "Testing"] scores = [95, 88, 72, 80] colors = ["#3498db","#2ecc71","#e74c3c","#9b59b6"] axes[0,1].bar(courses, scores, color=colors) axes[0,1].set_title("Avg Scores per Course") # Panel 3 โ Scatter np.random.seed(42) x_data = np.random.randn(80) y_data = x_data * 2.5 + np.random.randn(80) axes[1,0].scatter(x_data, y_data, alpha=0.6, c=y_data, cmap="viridis") axes[1,0].set_title("Study Hours vs Score") # Panel 4 โ Histogram data = np.random.normal(75, 12, 400) axes[1,1].hist(data, bins=20, color="steelblue", edgecolor="white") axes[1,1].axvline(data.mean(), color="red", linestyle="--", label=f"Mean={data.mean():.1f}") axes[1,1].set_title("Score Distribution") axes[1,1].legend() plt.tight_layout() plt.savefig("pynfinity_dashboard.png", dpi=120) plt.show() print("Dashboard saved โ pynfinity_dashboard.png")
Keep exploring and happy coding! ๐ป