☰

Lesson 11: Matplotlib Basics – Line Plots & Customization

1. What is Matplotlib?

Matplotlib is Python’s most popular plotting library β€” foundation for Seaborn, Pandas plots.

Install: pip install matplotlib

Import: import matplotlib.pyplot as plt

Exercise 1

Which line creates a simple line plot?

2. Basic Line Plot

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

plt.plot(x, y)
plt.title("Sine Wave")
plt.xlabel("x")
plt.ylabel("sin(x)")
plt.grid(True)
plt.show()

Used in ML: plot loss curves, predictions vs actual.

Exercise 2

To add title and labels:

plt.plot(x, y)
plt.("Training Loss")
plt.("Epochs")
plt.("Loss")

Exercise 3

Which are valid Matplotlib customizations?
← Previous Lesson (10) Next Lesson (12) β†’