Track 3 · Visualising and Exploring Data · Lesson 1 of 11

Choosing the right chart

Choose a chart from the question you are asking and the types of the variables involved, and explain why other charts would mislead or hide the answer.

25 minFoundation9 graded exercisesFree

An HR analyst is asked three questions in one meeting: how staff are spread across departments, how salaries are distributed, and whether experience pays. Each question needs a different chart — and the wrong one can hide the answer or invent a pattern that is not there.

A chart is an answer to a question. Before drawing anything, ask two things:

  1. What is the question? Comparing amounts between categories, describing how values are distributed, comparing distributions between groups, looking for a relationship, or following change over time.
  2. What types are the variables? A categorical variable puts each case in a group (department, travel mode); an ordinal one has groups with a natural order (job level L1–L5); a numeric variable is a measured quantity (salary, minutes). Time is numeric but special: it has a direction, so we read it left to right.

The chart follows from those two answers far more often than from taste.

QuestionVariablesDefault chartAlso good
How many in each group?One categoricalBar chart (sorted unless the categories are ordered)Dot plot of counts; a table for a few numbers
How are the values spread?One numericHistogramBox plot, density curve, ECDF
Do groups differ?Numeric by categoricalBox plots side by sideViolin or strip plots; small-multiple histograms
Are two quantities related?Two numericScatter plotScatter with a fitted line; hexbin when points overlap
How did it change?Numeric over timeLine chartSmall multiples for many series
How do two categorical variables combine?Two categoricalGrouped or 100% stacked barsA two-way table, a heatmap of counts
Question × variable types → a good default chart

Here is the first question applied to the (synthetic) salaries dataset: 600 employees in six departments. Department is categorical, so we count each group and draw one bar per department. Bar length encodes the count, and lengths starting from a common zero baseline are what the eye compares most accurately.

Bar chart of employee counts for six departments. Operations has the longest bar at 183 employees, followed by Sales and Technology; Human Resources has the shortest bar at 41.DepartmentCount
Employees per department. Operations is the largest (183 of 600); Human Resources is the smallest (41).
Show the data as a table
DepartmentCount
Operations183
Sales129
Technology125
Finance71
Human Resources41
Legal51

The second question — how are salaries distributed? — involves one numeric variable. A bar per distinct salary would be useless (almost every salary is unique), so a histogram groups the values into intervals (bins) and shows how many fall in each.

Histogram of 600 monthly base salaries: the tallest bars are between about 6 600 and 13 200 SAR, then the bars fall away into a long right tail reaching 63 600 SAR, with a small cluster around 44 000 to 50 000 SAR.Monthly base salary (SAR)Count
Monthly base salaries of 600 employees. Most are between about 7 000 and 20 000 SAR, with a long tail of senior salaries to the right.
Show the data as a table
FromToCount
66308821.1597
8821.1511012.395
11012.313203.5110
13203.515394.673
15394.617585.846
17585.819776.942
19776.921968.129
21968.124159.215
24159.226350.412
26350.428541.519
28541.530732.718
30732.732923.88
32923.8351153
3511537306.22
37306.239497.33
39497.341688.51
41688.543879.62
43879.646070.89
46070.848261.95
48261.950453.14
50453.152644.20
52644.254835.42
54835.457026.51
57026.559217.71
59217.761408.82
61408.8636001

To compare salaries between job levels (numeric by ordinal), put one box plot per level on a shared axis. Each box spans the middle half of the salaries in that level and the line inside is the median. Keep the levels in their natural order, L1 to L5, so the staircase is visible. The median rises from 8,690 SAR at L1 to 46,020 SAR at L5.

Five box plots of base salary, one per job level from L1 Associate to L5 Director. The medians climb steadily from 8,690 SAR at L1 to 46,020 SAR at L5, and the boxes of neighbouring levels hardly overlap.L1 AssociateL2 SpecialistL3 Senior SpecialistL4 ManagerL5 DirectorMonthly base salary (SAR)
Base salary by job level, in level order. Each level's box sits higher than the one before, and the boxes barely overlap.
Show the data as a table
GroupnLower whiskerQ1MedianQ3Upper whiskerOutliersMean
L1 Associate18366308060869096001166018859.89
L2 Specialist195954011790128001372516610112864.6
L3 Senior Specialist1271441016955188202043525060118857.2
L4 Manager6222370269702841530112.534370128398.4
L5 Director333775044050460204911055440647056.7

The question does experience pay? links two numeric variables, so each employee becomes one point on a scatter plot: years of experience across, salary up. The cloud rises from left to right (Pearson's r=0.76r = 0.76), and it fans out: salaries vary more among experienced staff.

Scatter plot of years of experience (0 to 38) against monthly base salary. The points rise from bottom left to top right with correlation 0.76, and the vertical spread of salaries widens as experience increases.Experience (years)Monthly base salary (SAR)
Experience against base salary for 600 employees. Salaries tend to rise with experience, and their spread widens.
Show the data as a table
Experience (years)Monthly base salary (SAR)
17.520260
2.49080
1113000
12.712460
1.87740
16.816940
12.320110
5.314220
7.522110
1.58590
211560
6.39740
4.59710
7.810880
6.910980
7.912800
12.921570
7.98130
12.320690
4.624160
3.113500
10.610960
6.410180
18.438710
5.714360
13.111960
25.442390
8.912540
14.69090
1117630
2.518040
2.59370
5.78560
7.213780
2.710120
14.923620
1.48890
27.730120
13.922370
5.711960
14.430090
12.927840
13.911950
2.48060
15.812120
24.963600
0.88380
627720
5.711300
12.615390
10.213960
8.811660
8.217820
19.317000
11.517170
16.919030
3.37980
9.211380
11.910140
5.712740
4.811550
15.629350
7.313140
22.244870
8.520930
6.414350
1.27270
610180
7.710620
11.516880
16.129440
18.222610
2.28360
7.912770
1425820
12.630780
4.211170
13.418730
6.77090
12.318320
10.515520
811990
2.213440
19490
7.115650
8.220480
10.214820
10.319720
1.98290
6.712210
8.913010
10.613250
5.712310
5.214760
7.913660
11.221860
12.817230
11.113900
8.411450
2.69440
10.414440
5.210960
12.547310
2.710590
6.713080
8.811790
3.19220
7.410300
6.711410
916200
18.646590
31.344050
5.811230
7.28040
7.611100
5.39850
1.89240
10.815740
7.49550
4.98580
4.17780
1.47910
3.88350
915100
2.77950
5.710920
89220
14.713150
6.38570
4.69400
1119100
12.322040
3.67820
17.112630
16.314790
11.520840
5.49800
6.48330
11.614520
5.310550
13.116250
11.112840
7.915260
15.218490
11.213140
3.98460
1.618680
2.39280
8.28300
5.312380
21.318980
20.632840
6.912690
4.411490
4.38090
7.314400
11.216860
13.320540
5.312120
22.528400
5.49050
3.69190
3.48740
15.313620
13.819150
1112930
9.611830
8.714150
9.314310
712830
7.314240
13.413450
9.319850
12.413760
8.611170
24.922540
1.88270
6.67850
11.915500
16.522050
19.419280
2544160
19630
5.710900
10.417940
17.519730
8.218820
3.67720
25.629020
10.422170
1.88900
10.820490
7.412930
5.213310
10.410120
8.17780
1.915420
8.813690
23.946870
8.98500
9.213540
49810
11.113800
25.129680
22.534370
35.561210
2.57530
4.814470
4.812300
11.611900
5.37950
4.99000
25.949110
11.526610
2.219610
2.210480
10.513240
9.68950
9.716560
2.48110
15.515790
810630
3.810860
10.111330
5.113510
13.915830
8.716850
9.612830
37640
10.220120
5.89180
16.754000
6.38210
8.513250
313420
5.714020
12.315400
8.425590
14.816790
2319280
17.211830
4.17790
12.228590
13.533740
19.932390
4.810400
6.88030
4.67850
3.612800
9.612190
22.727730
9.729450
5.212450
519550
11.925440
9.311380
11.516880
11.314370
11.410340
4.512610
2.310370
4.211950
5.27380
10.710850
1719470
20.317790
6.58300
9.710410
10.212680
34.455440
4.39930
4.515160
11.311980
4.88880
9.68330
26.654590
5.511910
1227560
513490
15.819370
6.38430
5.67720
6.58100
915460
3.98950
13.112020
8.211860
1.613090
12.313260
148720
7.525330
1.88410
11.511610
10.212980
8.814150
12.829280
18.623800
3.28060
1211350
4.58320
13.316410
17.216610
4.416900
21.312690
7.710080
6.117000
12.321610
10.917430
9.27550
10.819300
5.37110
69600
0.97980
2.88730
4.89530
1527260
15.721000
5.98340
310860
3.118170
17.917260
3.413840
11.212610
10.520940
7.312610
5.912000
0.58980
9.516740
6.79010
9.525670
15.628960
8.412690
30.235240
5.39860
3.68300
3.99000
19.919590
23.919810
2.89220
17.516950
14.127720
24.515450
12.212970
33.548310
5.211290
7.17450
15.721510
19.420560
13.428290
15.728980
17.423710
1919730
3.214410
1421780
3.27790
1028370
10.411060
7.512200
9.911080
2.611270
15.616920
5.413590
15.616540
12.911510
1120160
0.811380
4.110340
16.219400
3.111720
16.328430
3.89340
7.512370
5.19570
915840
7.919930
18.131690
913250
17.330960
6.28060
7.812830
6.712070
5.48540
3.79150
6.312590
16.817140
34.248520
7.913760
9.413430
9.113540
8.510990
7.39350
19.842320
21.628460
37.747070
4.916770
7.830470
15.116960
22.118970
5.815380
10.49490
9.39270
11.58130
23.527910
3844700
2.49550
13.714950
68460
20.646860
2.88690
2.710460
17.121280
26.144740
9.121120
5.317750
7.714160
10.817910
13.928030
7.29930
19.727180
1819630
3.211210
13.640550
15.923530
13.217460
3.58200
14.228880
1021760
11.946020
7.29780
5.912550
7.811900
3.725410
4.816930
3760430
2.58720
5.213280
24.744740
16.717970
1114320
5.213350
4.917360
10.727750
15.815110
18.331270
13.818930
10.28140
88550
22.918970
14.727790
7.513290
13.115130
7.88150
711630
8.27780
13.312820
12.819610
10.415370
13.630330
2.910740
2.48400
6.711390
3.88460
2245820
2.810120
6.67130
1.97540
7.28260
9.711790
9.914980
2.77590
4.69460
21.139460
2518810
910800
2.98740
17.312870
2.47400
611230
13.225860
6.211150
4.518180
7.815720
8.715350
7.830120
79600
4.67980
8.311700
4.39830
9.614540
211560
16.427120
17.630370
16.613340
2.611130
18.225060
1610360
20.523310
19.620390
8.914040
7.77590

First 500 of 600 rows.

Finally, numbers recorded over time call for a line chart, because the line joining consecutive months shows direction and rhythm. Below, eight years of monthly demand for three products: each has its own seasonal peak.

  • Ceiling fan
  • Water heater
  • School backpack
Line chart of monthly units for three products over 96 months. Ceiling fans show tall summer peaks that grow slowly; water heaters peak each winter and drop to a lower level from month 61; school backpacks are flat except for a sharp spike every August.Month indexUnits demanded (units)
Monthly units ordered for three products over 96 months (synthetic). Fans peak every summer, water heaters every winter, backpacks every August.
Show the data as a table
Month indexCeiling fanWater heaterSchool backpack
1123224301080
214812264429
319481483453
424271304539
53360876504
64211837489
74240629944
845247263144
928229371183
1022421382495
1115842008534
1212242611462
13144026161091
1413852242551
1517611566410
1625511282448
1735451022508
184415884531
1940397471054
2043517923144
21333510061105
2222471455586
2314721923534
2412332317520
25130127621070
2614812234578
2719571634432
2828131211410
293940852485
304544773575
314511674988
3241597463616
3331339371371
3421711476529
3515322119527
3616412863470
37129926351154
3814122391523
3920041891372
4029911263429
4139511051526
424086762514
4348876901030
4442627903049
45373111031157
4622301625563
4717352193462
4815143027486
4913622629975
5018912255542
5121672020431
5231361277445
534405959605
544744916470
555290615974
5648158423317
57324410711215
5824151611514
5916902000511
6012322637491
61153518051167
6217681898553
6322081326432
642791862481
654240816440
665441652549
6749765321000
6848666443237
6934038731266
7026311116566
7119611720555
7213102102454
73162718711184
7419851943531
7525081514508
763386962433
773874834511
785516633502
7959296591025
8045216503207
8141828701173
8227681213629
8320241507526
8413992115487
85156122911061
8617661721473
8724011296501
8827511052547
894458779525
905186724557
915489578992
9257307022938
9340698721256
9429371233460
9518811780465
9617312036474
Loading the interactive…
Choose one or two variables from the salaries dataset; the builder suggests suitable charts and explains why others do not fit.

Try this

  • Pick department alone, then base_salary_sar alone. Why does the builder switch from a bar chart to a histogram?

  • Pick base_salary_sar with job_level. Which chart is suggested, and why is a scatter plot not offered?

  • Pick years_experience with base_salary_sar. What does the builder say about a line chart for these two variables?

Worked example

Choosing for a manager's question

A manager asks: “Do Sales staff get bigger bonuses than Technology staff?” Which chart should you draw from the salaries data?

  1. Question type. It compares a quantity between groups.

  2. Variable types. annual_bonus_sar is numeric; department is categorical (we keep just two of its levels).

  3. Default chart. Numeric by categorical → box plots side by side on one shared axis.

  4. Check the data. About 29% of bonuses are exactly zero. A box plot alone can hide that spike, so add the share with no bonus in the caption, or show strip plots of the individual values.

Side-by-side box (or strip) plots of bonus for Sales and Technology on a common axis, with the percentage receiving no bonus reported for each.

Quick check

You want to show what share of 600 employees work in each of six departments. Which chart is the safest default?

Exercises

The lesson is complete when every exercise is answered correctly. Hints are free; viewing a worked solution before solving means the exercise won't count towards mastery.

0 of 9 exercises correct (not saved — sign in to keep your progress)

Exercise 1 · Guided, difficulty 1 of 3

From question to chart

Not started

Sort each question into the chart that answers it best by default.

Which payment method do customers use most often?
How are basket values (SAR) spread — symmetric or with a long tail?
Are flight delays longer for some airlines than others?
Do larger homes sell for higher prices?
How have weekly sales at one store changed over two years?
How many employees are in each job level, L1 to L5?
Is engagement score different across six departments?

Exercise 2 · Practice, difficulty 1 of 3

Match the variables to a chart

Not started

Each item names variables from the library datasets. Match each to the most suitable default chart.

department (salaries)
commute_min (commute)
base_salary_sar by gender (salaries)
tv_spend_ksar and sales_units (advertising)
units against month for one product (monthly_demand)

Exercise 3 · Application, difficulty 1 of 3

Read the department bar chart

Not started

The bar chart in the lesson shows how many of the 600 employees work in each department. What percentage of employees work in Operations? Use the salaries dataset (or the chart's data table) and give the answer to 1 decimal place.

Data: salaries · Open in the lab to explore and calculate.

Exercise 4 · Application, difficulty 2 of 3

Read a median off the box plots

Not started

In the box plots of base salary by job level, read the median monthly base salary of L4 Manager employees. Then check it from the data (the dataset here is filtered to the L4 rows). Enter the median in SAR; a reading within 2% is accepted.

Data: salaries (job_level = L4 Manager) · Open in the lab to explore and calculate.

SAR

Exercise 5 · Interpretation, difficulty 2 of 3

A pie of averages

Not started

A colleague draws a pie chart with one slice per department, where each slice's size is the department's average base salary. What is wrong with this chart?

Choose one

Exercise 6 · Practice, difficulty 2 of 3

Charts that can compare distributions

Not started

You want to compare the distribution of base salary across the five job levels (not just one average per level). Select all charts that can do this well.

Select all that apply

Exercise 7 · Practice, difficulty 1 of 3

Steps in choosing a chart

Not started

Put these steps for choosing and checking a chart in a sensible order.

Put the steps in order (use the arrows)

  1. 1Pick the default chart for that combination
  2. 2Add a title that states the finding, labelled axes and units
  3. 3Check the data for features the default could hide (zeros, outliers, small groups)
  4. 4Identify the variables involved and their types (categorical, ordinal, numeric, time)
  5. 5Write down the question the chart must answer

Exercise 8 · Practice, difficulty 1 of 3

How many employees in the biggest group?

Not started

A bar chart shows the number of employees in six departments of another (fictional) company:

DepartmentOperationsSalesTechnologyFinanceHuman ResourcesLegal
Employees10377120222192

What percentage of all employees are in the department with the tallest bar? Give your answer to 1 decimal place.

Exercise 9 · Interpretation, difficulty 2 of 3

Justify your chart

Not started

A director asks: “Do employees with more experience earn more — and is that pattern the same in every department?” In two or three sentences, say which chart you would draw from the salaries data and justify it (what goes on each axis, and how you would show department).

0 words

What you can now do

  • Start from the question and the variable types, not from a favourite chart
  • Use bars for categories, histograms for one numeric variable, box plots for groups, scatter plots for two numeric variables and lines for time
  • Read counts, shares and medians accurately from bar charts and box plots
  • Explain why pies of averages and lines through categories mislead