Skip to main content...
Python + Classical CV — the Catalog Tool
20 min

Day 6: Matplotlib: plotting distributions and images

Seeing your data before you trust it

Matplotlib is the plumbing every other Python plotting library sits on top of. You need exactly two things from it for this roadmap: plotting distributions (is this data sane?) and displaying images (did this CV step actually work, or did it silently produce garbage?). Both habits pay off immediately in Stage 0 and constantly afterward — a training curve in Stage 1, a segmentation mask in Stage 2.

Distributions: sanity-checking tabular data
import matplotlib.pyplot as plt

fig, axes = plt.subplots(1, 2, figsize=(10, 4))
axes[0].hist(orders["price"], bins=30)
axes[0].set_title("Price distribution")

axes[1].bar(return_rate_by_category.index, return_rate_by_category.values)
axes[1].set_title("Return rate by category")
plt.tight_layout()
plt.savefig("sanity_check.png")
Displaying images — the single most-used debugging tool for the rest of the roadmap
import cv2

img = cv2.imread("garment.jpg")
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)  # OpenCV loads BGR — see Day 8

plt.imshow(img_rgb)
plt.axis("off")
plt.title("Loaded garment photo")
plt.savefig("check.png")

Why this is worth a whole day

The single most common classical-CV bug is a pipeline that runs without errors but silently produces the wrong output — a background-removal mask that's inverted, a resize that squashed the aspect ratio. imshow at every pipeline stage is how you catch this in seconds instead of during Day 14's 20-photo validation.

Key terms

Histogram
A plot of how often values fall into each of a set of bins — the standard way to sanity-check a numeric distribution.
imshow
Matplotlib's function for rendering a 2D or 3D array as an image — the core debugging tool for any CV pipeline.

A background-removal function runs without any errors, but the output looks wrong when you actually view it. What should you have done earlier?

We use cookies

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. Learn more

    Day 6: Matplotlib: plotting distributions and images | RBTechIconX