Data Science Track · Lesson 5

Data Visualisation

The right chart makes a pattern obvious in seconds. The wrong chart hides it forever. Here's how to choose.

Why Visualise at All?

The human brain processes visual information roughly 60,000× faster than text. A pattern that would take minutes to spot in a table of 1,898 numbers becomes obvious in 2 seconds on a chart. But this power cuts both ways — a misleading chart can be just as convincing as an honest one.

Anscombe's Quartet is a famous demonstration: four datasets with nearly identical means, variances, and correlations — yet completely different shapes when plotted. Without visualisation, you'd treat them identically and reach completely wrong conclusions.

The purpose of a chart A chart should answer one specific question. Before you plot anything, ask: "What am I trying to find out?" The answer determines the chart type. Building a chart and then looking for a question is backwards.

The Core Chart Types

Use for: Distribution of one numeric variable

Histogram

Groups values into bins (ranges) and shows how many observations fall in each bin. The shape reveals everything: Is the data symmetric? Skewed? Bimodal? Are there gaps? The x-axis is the value, the y-axis is the count. Key reading: if the right tail is long (right-skewed), the mean will be pulled above the median — most values cluster low, but a few large values drag the average up. FoodHub order cost: right-skewed, peak around $12–14, long tail toward $35.

Use for: Summarising distribution + spotting outliers

Boxplot (Box-and-Whisker)

Shows the 5-number summary in a single shape: the box spans Q1 to Q3 (the IQR — the middle 50%). The line inside the box is the median. The whiskers extend to the fences (Q1 − 1.5×IQR and Q3 + 1.5×IQR). Any points beyond the whiskers are outliers, plotted individually as dots. Boxplots are especially powerful for comparing distributions across groups — stack them side by side and you can instantly see whether group A or group B tends higher, wider, or more skewed.

Use for: Comparing counts or values across categories

Bar Chart (Countplot)

Each bar represents a category, and its height represents a count or a value. Simple, universally understood, and highly effective for answering "which category is biggest?" questions. Use horizontal bars when category names are long (they fit without rotation). Avoid 3D bars — they distort perception. FoodHub: top restaurants by orders, cuisine types by volume.

Use for: Relationship between two numeric variables

Scatter Plot

Each dot represents one observation, placed at coordinates (x, y) for two numeric variables. Patterns become visible: upward trend = positive correlation, downward trend = negative, cloud = no relationship, curved band = non-linear relationship. Clusters suggest sub-groups. Isolated dots far from the cloud are multivariate outliers — normal on each axis individually but abnormal in combination.

Use for: All pairwise relationships at once

Pairplot (Scatter Matrix)

A grid of scatter plots. Every row and column is a variable. Where two different variables intersect, you get a scatter plot of one against the other. Where a variable meets itself (the diagonal), you get its distribution (histogram or KDE). A pairplot on 4 variables produces a 4×4 = 16-panel grid. It's a quick overview: are there any relationships worth investigating further? FoodHub result: almost all scatter plots showed random clouds — the variables are largely independent of each other.

Use for: Showing correlation strength between many variables

Heatmap (Correlation Matrix)

A colour-coded grid where each cell shows the correlation between two variables. Colour intensity = strength. The diagonal is always 1.0 (every variable perfectly correlates with itself). Symmetric about the diagonal. Good colour schemes: diverging (blue–white–red or green–white–red) so positive, zero, and negative correlations are visually distinct. The FoodHub heatmap showed that only prep_time and total_time had a meaningful correlation — which makes sense, since total_time = prep_time + delivery_time.

Chart Selection Quick Reference

What are you trying to show?

Distribution of one numeric variable→ Histogram or Boxplot
Count of categories→ Bar Chart
Relationship between two numeric variables→ Scatter Plot
Distribution across groups→ Side-by-side Boxplots
All pairwise relationships→ Pairplot
Correlation strengths→ Heatmap
Trend over time→ Line Chart
Part of a whole→ Pie Chart (≤5 categories) or Stacked Bar

Common Mistakes to Avoid

Truncated y-axis Starting the y-axis at a value other than zero makes small differences look enormous. A chart showing revenue going from $980K to $1,020K looks dramatic if the y-axis starts at $970K. Always check where the y-axis starts.
Cherry-picking the time range Choosing a date range that starts at a convenient low point and ends at a high point makes any trend look stronger than it is. Always show the full available history.
Too many categories in a pie chart Humans can't accurately judge small angle differences. A pie chart with 8 slices is nearly unreadable. Use a bar chart instead — length is far easier to compare than area or angle.
In the FoodHub Project

Every chart type from this lesson appeared in the analysis. Histograms showed the right-skewed cost distribution. Boxplots revealed delivery time outliers. Bar charts ranked restaurants and cuisines. Scatter plots checked for cost–time relationships (finding none). A pairplot confirmed the independence of variables at a glance. The heatmap made the correlation structure unmistakable. See Chapter 4 — Distributions →