02-02: Exercises — Graphical Displays¶
Notes reference: 02-02: Graphical Displays
Q1: Pick the right graph¶
Name the best graph for each task.
- Show what share of total revenue each of 4 product lines contributes.
- Compare the distribution of salaries in three departments.
- Show the shape of 200 reaction times.
- Show how many customers are at or below each spending level.
- Show 15 test scores while keeping the original values visible.
- Show whether study hours and exam score move together.
- Show monthly website visits over three years.
- Rank 8 defect causes and show the cumulative share.
Solution
1. PIE CHART (or a sorted bar chart — easier to compare 4 slices)
2. SIDE-BY-SIDE BOXPLOTS
3. HISTOGRAM
4. OGIVE (cumulative frequency graph)
5. STEM-AND-LEAF PLOT — shape plus every original value
6. SCATTERPLOT
7. TIME SERIES PLOT (line chart)
8. PARETO CHART
Q2: Bar chart or histogram?¶
For each, say which applies and whether the bars touch.
| Data | Graph | Bars touch? |
|---|---|---|
| Blood type of 200 donors | ? | ? |
| Weight of 200 donors, grouped into classes | ? | ? |
| Number of children per family (0,1,2,3,4) | ? | ? |
Solution
| Data | Graph | Bars touch? |
|---|---|---|
| Blood type | Bar chart — nominal categories | No — separated |
| Weight, grouped | Histogram — continuous scale | Yes — touching |
| Number of children | Bar chart — discrete counts, treated as categories | No (though some texts allow a histogram-style plot) |
' To make histogram bars touch in Excel:
' right-click the series ▸ Format Data Series ▸ Gap Width = 0%
Q3: Build a stem-and-leaf plot¶
Twenty-two scores:
Draw the stem-and-leaf plot with a key, then state the shape.
Solution
Stem | Leaf
-----+---------------------------
3 | 4 8
4 | 1 3 5 7 8
5 | 0 2 3 5 6 7 8
6 | 0 2 3 5 7
7 | 1 4 8
Key: 5 | 2 = 52
Q4: Read a boxplot¶
A boxplot of house prices (in $000s) shows: minimum whisker 180, Q1 245, median 290, Q3 380, upper whisker 520, with two dots at 720 and 850.
- What is the IQR?
- What are the outlier fences?
- Are the two dots correctly flagged?
- Describe the skew.
Solution
1. IQR = Q3 − Q1 = 380 − 245 = 135
2. Lower fence = 245 − 1.5(135) = 245 − 202.5 = 42.5
Upper fence = 380 + 1.5(135) = 380 + 202.5 = 582.5
3. 720 and 850 both exceed 582.5 → YES, correctly flagged as outliers.
The upper whisker stops at 520, the largest value INSIDE the fence. ✓
4. Median (290) sits LEFT of the box centre ((245+380)/2 = 312.5),
the right whisker (380→520 = 140) is longer than the left (245→180 = 65),
and both outliers are on the high side.
→ RIGHT-SKEWED (positively skewed) — the usual shape for house prices.
→ Report the MEDIAN and IQR, not the mean and SD.
Q5: Frequency polygon and ogive¶
Using the commute-time distribution from 02-01:
| Class | Xm |
f |
Upper boundary | Cum f |
|---|---|---|---|---|
| 10–19 | 14.5 | 3 | 19.5 | 3 |
| 20–29 | 24.5 | 4 | 29.5 | 7 |
| 30–39 | 34.5 | 8 | 39.5 | 15 |
| 40–49 | 44.5 | 7 | 49.5 | 22 |
| 50–59 | 54.5 | 5 | 59.5 | 27 |
| 60–69 | 64.5 | 3 | 69.5 | 30 |
State exactly which (x, y) pairs you plot for (a) the frequency polygon and (b) the ogive.
Solution
(a) FREQUENCY POLYGON — plot (MIDPOINT, frequency), closing on the axis:
(4.5, 0) (14.5, 3) (24.5, 4) (34.5, 8) (44.5, 7) (54.5, 5) (64.5, 3) (74.5, 0)
↑ one class below ↑ one class above
with f = 0 with f = 0
(b) OGIVE — plot (UPPER BOUNDARY, cumulative frequency), starting at 0:
(9.5, 0) (19.5, 3) (29.5, 7) (39.5, 15) (49.5, 22) (59.5, 27) (69.5, 30)
↑ the LOWER boundary of the first class, at cumulative frequency 0
The two most common errors: plotting the polygon at boundaries instead of midpoints, and plotting the ogive at limits instead of boundaries.
' Both are Scatter with Straight Lines and Markers.
' Build two columns (x and y) exactly as listed above, then Insert ▸ Scatter.
Q6: Diagnose the shape¶
Match each description to its shape, and say which centre and spread to report.
- Household income for a city
- Heights of adult women
- Scores on a very easy test where most students scored 90+
- The last digit of 500 phone numbers
- Heights of a mixed group of adult men and women
Solution
| # | Shape | Report |
|---|---|---|
| 1 | Right-skewed — a long tail of high earners | Median, IQR |
| 2 | Symmetric / bell-shaped | Mean, standard deviation |
| 3 | Left-skewed — a tail of low scores | Median, IQR |
| 4 | Uniform — each digit equally likely | Range; a mean is meaningless here |
| 5 | Bimodal — two overlapping subgroups | Split by sex and describe each separately |
Rule of thumb that covers 1–3: the MEAN gets dragged toward the long tail.
mean > median → right-skewed
mean < median → left-skewed
Q7: Spot the misleading graph¶
A press release shows a bar chart of quarterly sales: Q1 = 4.8 M, Q2 = 5.0 M, Q3 = 5.1 M. The vertical axis runs from 4.7 to 5.2 and Q3's bar looks four times taller than Q1's. The headline reads "Sales quadruple!"
What is wrong, and how would you redraw it?
Solution
PROBLEM TRUNCATED AXIS. A bar chart encodes value as BAR LENGTH, so its
axis must start at 0. Starting at 4.7 turns a 6% rise (4.8 → 5.1)
into a bar that is visually 4× longer.
The real change: (5.1 − 4.8) / 4.8 = 6.25% growth over two quarters.
FIX 1. Start the vertical axis at 0.
2. If the differences are then too small to see, use a LINE CHART
(which encodes value by position, where a truncated axis is
conventional and acceptable) and label the axis clearly.
3. Or plot the percentage change directly, which is what the
headline is actually about.
4. Rewrite the headline: "Sales up 6% since Q1".
Q8: Reproduce a figure in all three tools¶
Produce a histogram of x with 6 classes plus a boxplot beneath it, in Excel, R, and Python.
Solution
' HISTOGRAM
' Option A: Insert ▸ Insert Statistic Chart ▸ Histogram,
' then right-click the horizontal axis ▸ Format Axis ▸
' Number of bins = 6
' Option B: Data ▸ Data Analysis ▸ Histogram with a Bin Range of
' upper class limits, tick Chart Output, then set
' Format Data Series ▸ Gap Width = 0
'
' BOXPLOT
' Select the data ▸ Insert ▸ Insert Statistic Chart ▸ Box and Whisker
' Format Data Series ▸ tick "Show mean markers"
par(mfrow = c(2, 1), mar = c(4, 4, 2, 1))
hist(x, breaks = 6, col = "#8A5FBF", border = "white",
main = "Distribution of x", xlab = "")
boxplot(x, horizontal = TRUE, col = "#0FA3A3", xlab = "x")
par(mfrow = c(1, 1))
# ggplot2 version
library(ggplot2)
ggplot(data.frame(x), aes(x)) +
geom_histogram(bins = 6, fill = "#5B2A86", colour = "white") +
theme_minimal()
import matplotlib.pyplot as plt
fig, (a1, a2) = plt.subplots(2, 1, figsize=(7, 5), sharex=True,
gridspec_kw={"height_ratios": [3, 1]})
a1.hist(x, bins=6, color="#8A5FBF", edgecolor="white")
a1.set(ylabel="Frequency", title="Distribution of x")
a2.boxplot(x, vert=False, showmeans=True)
a2.set(xlabel="x", yticks=[])
plt.tight_layout(); plt.show()
⬅️ Previous: 02-01: Exercises — Frequency Distributions ➡️ Next: 03-01: Exercises — Mean, Median and Mode