Data visualization means showing data as a picture, a chart, graph or map, so people can understand it quickly. A table of 365 daily temperatures is just numbers; a line chart of the same data shows summer, winter and the heatwave in May at a glance.
This lesson explains why our brains understand charts faster than tables, shows a famous example where the summary numbers lie but the chart doesn't, and covers what makes a chart good. It's the first lesson of the Python charts course, so there's no setup needed to read it; if you want to run the code, see set up a machine learning environment in Python, which installs everything this course uses.
Why charts beat tables
Here are a shop's monthly sales, in thousands of rupees:
| Month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Sales | 42 | 40 | 45 | 47 | 44 | 46 | 48 | 50 | 52 | 75 | 88 | 55 |
Which month was best? You can find it by reading every number. Now look at the same numbers as a chart:
import matplotlib.pyplot as plt
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
sales = [42, 40, 45, 47, 44, 46, 48, 50, 52, 75, 88, 55]
plt.plot(months, sales, marker="o")
plt.title("Monthly sales (₹ thousand)")
plt.show()
You see the story instantly: steady growth through the year, then a big festive-season spike in October and November. Your eyes found the pattern before you read a single number.
That's because the brain processes position, length, colour and shape almost automatically, in a fraction of a second, while reading and comparing numbers takes deliberate effort. A good chart hands the hard work to your visual system.
Tables still have their place. Use a table when people need to look up exact values; use a chart when they need to see patterns, trends, comparisons or outliers.
The numbers can lie: Anscombe's quartet
In 1973, the statistician Francis Anscombe created four small datasets that have almost identical summary statistics. Seaborn includes them:
import seaborn as sns
df = sns.load_dataset("anscombe")
summary = df.groupby("dataset").agg(
x_mean=("x", "mean"), y_mean=("y", "mean"),
y_std=("y", "std"),
)
summary["correlation"] = df.groupby("dataset")[["x", "y"]].apply(
lambda g: g["x"].corr(g["y"]))
print(summary.round(2))
x_mean y_mean y_std correlation
dataset
I 9.0 7.5 2.03 0.82
II 9.0 7.5 2.03 0.82
III 9.0 7.5 2.03 0.82
IV 9.0 7.5 2.03 0.82
Same means, same spread, same correlation. By the numbers, they're the same data. Now plot them:
sns.lmplot(data=df, x="x", y="y", col="dataset", col_wrap=2,
ci=None, height=3)
plt.show()
They're completely different:
- I is a normal, noisy straight-line relationship.
- II is a curve, so a straight line is the wrong model.
- III is a perfect line spoiled by one outlier.
- IV has no real relationship at all; one extreme point creates the "correlation".
The lesson: always plot your data before trusting summary numbers. That's why exploratory data analysis and machine learning projects start with charts.
What data visualization is used for
- Exploring data you've just received: its shape, gaps and oddities. These charts are quick and rough, just for you.
- Explaining a finding to others: a manager, a client, a report. These need care: clear titles, labels and one main message.
- Monitoring things that change: dashboards of sales, website traffic or server health.
Most charts you make will be exploratory, and many will be thrown away. That's normal.
What makes a good chart?
- It answers one question. "Which month had the most sales?" leads to a different chart from "how did sales change over the year?".
- It's the right type. Lines for change over time, bars for comparing categories, scatter plots for relationships. The next lesson, how to choose the right chart, covers this.
- It's clearly labelled: a title that says what it shows, axis labels with units, a legend if there are several series.
- It's honest. Bar charts start at zero; axes aren't stretched to exaggerate a change; nothing important is hidden.
- It has no clutter. Remove heavy gridlines, 3D effects, shadows and decorations that don't carry information.
- It works for everyone. Avoid relying on red versus green alone, since about 1 in 12 men has some colour vision deficiency.
Why Python for charts?
Spreadsheet charts are fine for one-off work. Python charts are better when:
- the data is large or needs cleaning first,
- you make the same chart repeatedly, such as every month, and want it to update with one command,
- the chart is part of an analysis in pandas or a machine learning project,
- you need full control over every detail.
This course uses the two most popular libraries: Matplotlib, which can draw almost anything, and Seaborn, built on top of it, which makes statistical charts from pandas DataFrames in a line or two. Later lessons add Plotly for interactive charts.
Practice
- For each question, would you use a table or a chart? (a) What was the exact fee paid by student 1042? (b) Did attendance fall over the semester? (c) Which of 8 departments has the most students?
Show the answer
(a) A table: it's a lookup of one exact value. (b) A chart, a line over time. (c) A chart, a bar chart comparing categories, though a sorted table also works for just 8 values.
- Why might two datasets with the same mean and correlation need different models?
Show the answer
Summary statistics hide the shape of the data: a curve, outliers or clusters can produce the same numbers as a straight-line relationship. Anscombe's quartet shows four such cases; only a chart reveals them.
- Change the sales example to plot a bar chart with
plt.bar(months, sales). Which makes the festive spike easier to see?
Show the answer
Both show it. The line chart emphasises the trend over time, which suits monthly data; the bar chart emphasises comparing individual months.
Interview questions
What is data visualization and why is it important?
The graphical representation of data to reveal patterns, trends, comparisons and outliers. It's important because people see visual patterns far faster than they read numbers, and because summary statistics can hide the true shape of data.
What is Anscombe's quartet?
Four datasets with nearly identical means, variances, correlations and regression lines that look completely different when plotted. It demonstrates why you should always visualise data rather than rely only on summary statistics.
What makes a chart effective?
It answers a clear question, uses an appropriate chart type, is clearly titled and labelled with units, represents data honestly (for example, bar charts start at zero), avoids clutter, and is accessible, including to colour-blind readers.
What to learn next
- Pick the right chart every time with how to choose the right chart for your data.
- Make your own in your first chart in Python, step by step.