Code of the Day
IntermediateVisualisation

Lab: visual summary

Build a four-panel figure — distribution, correlation, grouped comparison, and trend — from a single inline dataset.

Lab · optionalData ScienceIntermediate30 min
By the end of this lesson you will be able to:
  • Choose the correct chart type for each of four distinct analytical questions
  • Assemble a multi-panel figure with plt.subplots()
  • Apply data-ink ratio and annotation principles to each panel

This is an optional lab. No new concepts — just practice choosing the right chart, building it in code, and applying the design principles from this module to a dataset you have not seen before.

The dataset is student exam scores across three subjects, collected over two academic years. Your goal is to build a four-panel figure that answers four different questions about the data.

Step 1 — inspect the dataset

Python — editable, runs in your browser

Before building any chart, decide which question each panel will answer:

  1. Distribution — what does the spread of maths scores look like?
  2. Correlation — how do the three subjects relate to each other?
  3. Grouped comparison — do average scores differ between Y1 and Y2?
  4. Trend — how does the average score per subject change across student IDs?

Step 2 — distribution panel

A histogram is the right chart for "what does the spread look like?" Run this block to build the first panel:

Python — editable, runs in your browser

Step 3 — correlation panel

Use a seaborn heatmap on the three subject columns:

Python — editable, runs in your browser

Step 4 — grouped comparison panel

A bar chart comparing mean scores by year and subject:

Python — editable, runs in your browser

Step 5 — trend panel

A line chart showing rolling average score per subject across student IDs:

Python — editable, runs in your browser

In a real project you would assemble all four panels into one figure using fig, axes = plt.subplots(2, 2, figsize=(12, 8)) and pass each axes[i][j] to the relevant plotting call. The individual blocks above are intentionally separate to make each step easy to inspect and debug.

Done?

You have produced four chart types for four different analytical questions, using matplotlib and seaborn, and applied the design principles from the Anatomy lesson (spine removal, frameon=False, meaningful annotation). The next module — Feature Engineering — shifts focus from visualising data to preparing it for a machine learning model.

Finished reading? Mark it complete to track your progress.

On this page