Quick Stats
Completed
0
Time Spent
0m
Streak
0
User
Visualizing Data with Matplotlib
See the shape of your data.
A chart beats a column of numbers
Tables tell you what the data is; charts tell you what it means. A trend, an outlier, or a lopsided distribution that hides in a wall of numbers jumps out instantly in a plot. Matplotlib is Python's foundational plotting library, and pandas builds convenient charting right on top of it.
The quickest path: plot from pandas
You often don't need Matplotlib directly — a DataFrame can plot itself:
import pandas as pd
df = pd.read_csv("data.csv")
df["age"].plot(kind="hist") # distribution of one column
df.plot(kind="scatter", x="age", y="income")
df.groupby("city")["sales"].sum().plot(kind="bar")Each line turns a table into a picture with almost no ceremony.
The charts you'll reach for
- Histogram — the distribution of one variable. Is it bunched, spread, skewed?
- Scatter — the relationship between two variables. Do they move together?
- Bar — compare a value across categories (sales by city).
- Line — change over time.
Match the chart to the question: one variable's shape (histogram), two variables' relationship (scatter), comparisons (bar), trends (line).
Honest charts
A chart persuades, so it carries responsibility. Label your axes, start them sensibly, and don't pick scales that exaggerate. The goal is understanding first, presentation second.
Always look at your data before you model it. Five minutes of plotting reveals outliers, errors, and patterns that summary statistics quietly hide.
Try this: Load a dataset and make three quick plots: a histogram of one column, a scatter of two columns, and a bar chart of a grouped total. Whatever surprises you in those three pictures is exactly what you'd have missed by reading the numbers alone.