Matplotlib

🧠 What is Matplotlib

Python’s core plotting library. Everything else (Seaborn, Pandas .plot()) is built on top of it. Two APIs:

APIStyleUse for
pyplot (plt)Implicit, MATLAB-style, tracks “current” figure/axesQuick, one-off plots
Object-oriented (fig, ax)Explicit, you hold referencesMulti-panel plots, reusable code, production

Default to the OO API ( fig, ax = plt.subplots()) even for simple plots. Scales better, avoids "current axes" confusion.

📚 Map of Content

⚡ Minimal example

import matplotlib.pyplot as plt
 
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 1, 5])
ax.set_title("My Plot")
plt.show()
pip install matplotlib