Ravindra BagaleCourses & study guides

13. Visualization with matplotlib

13.1 Figure and Axes

import matplotlib.pyplot as plt
import pandas as pd

gmv = pd.Series(
    {"Pune": 220000, "Nashik": 140000, "Nagpur": 90000,
     "Solapur": 70000, "Kolhapur": 65000, "Sambhaji Nagar": 80000}
)

fig, ax = plt.subplots(figsize=(8, 4))
ax.bar(gmv.index, gmv.values)
ax.set_title("Fictional Blinkit GMV by City — Oct 2026")
ax.set_xlabel("City")
ax.set_ylabel("GMV (₹)")
plt.xticks(rotation=30, ha="right")
fig.tight_layout()
plt.show()

Prefer fig, ax = plt.subplots() over only plt.bar — easier when you add a second chart later.