Skip to content
Tactiverge

Visualising data honestly

Choose the right kind of plot for your data, label it fully, and recognise the tricks that make charts mislead.

Lesson 3 of 6 · 25 min · Self-paced · Free

Why plot at all?

Summary statistics squeeze a dataset into a few numbers, and squeezing loses information. Two sets of sensor readings can share the same mean and standard deviation while one is a smooth drift and the other is two separate clusters. A plot shows you shape, trends, gaps and outliers in a second, and it is often the moment you discover that something went wrong in an experiment. Plot your data before you trust any summary of it.

Plots are also how you communicate results. A clear plot lets a reader check your claim with their own eyes. A misleading plot can persuade people of something the data does not support, sometimes without the author meaning to.

Choose the plot that matches the question

  • Line plot: one quantity changing over time or along an ordered axis, such as a joint angle sampled every 10 ms. The line implies the values are connected, so do not use it for unrelated categories.
  • Scatter plot: the relationship between two measured quantities, such as load and extension of a spring. Each point is one observation. This is the plot behind line fitting and correlation, later in this module.
  • Histogram: the distribution of one quantity. Divide the range into equal-width bins and count how many values fall in each. It shows whether data is bunched, skewed, or has more than one peak.
  • Bar chart: a quantity for a few separate categories, such as success rate for three gripper designs. Add error bars and state n.
  • Dot plot or strip plot: every individual value for a few groups. With small samples (say, under 20 per group), showing every point is more honest than a bar, because a bar hides how many values there are and how they are spread.

A histogram with only the standard library

You do not need special software to see a distribution. This program bins 60 simulated distance readings (made-up data, generated with a fixed seed) and prints a text histogram:

import random

random.seed(3)
# Made-up data for illustration: 60 simulated distance readings (cm)
readings = [round(random.gauss(30.0, 0.5), 1) for _ in range(60)]

bin_width = 0.5
start = 28.5
counts = {}
for r in readings:
    b = start + bin_width * int((r - start) // bin_width)
    counts[b] = counts.get(b, 0) + 1

for b in sorted(counts):
    print(f"{b:4.1f}-{b + bin_width:4.1f} cm | {'#' * counts[b]}")

Output:

28.5-29.0 cm | ###
29.0-29.5 cm | #########
29.5-30.0 cm | #######################
30.0-30.5 cm | ###############
30.5-31.0 cm | #########
31.0-31.5 cm | #

Each bin includes its left edge and excludes its right edge, so a reading of exactly 29.0 cm is counted in the 29.0–29.5 bin. Try changing bin_width to 0.2 or 1.0. Bins that are too wide hide the shape; bins that are too narrow make random noise look like structure. There is no single correct width, which is itself a reason to be careful: a histogram's message can depend on a choice the reader never sees.

Making a proper plot with matplotlib (optional)

For real reports, most Python users use the matplotlib library. It is not part of the standard library, so it must be installed first (for example with pip install matplotlib), and many free online Python environments already include it. This example plots means with standard-error bars:

import matplotlib.pyplot as plt

# Made-up data for illustration
load_n = [0, 1, 2, 3, 4, 5]
extension_mm = [0.1, 2.1, 3.9, 6.2, 7.9, 10.1]
se_mm = [0.1, 0.1, 0.2, 0.2, 0.2, 0.3]

plt.errorbar(load_n, extension_mm, yerr=se_mm, fmt="o", capsize=4)
plt.xlabel("Load (N)")
plt.ylabel("Extension (mm)")
plt.title("Spring extension vs load (mean ± SE, n = 5 per load)")
plt.xlim(left=0)
plt.ylim(bottom=0)
plt.grid(True, alpha=0.3)
plt.savefig("spring.png", dpi=150)

Every element earns its place: axis labels with units, a title that says what the error bars mean and how many trials each point represents, and a grid that helps readers read values.

How charts mislead

Most misleading charts come from a handful of tricks. Learn to spot them in other people's work and to avoid them in your own.

1. A bar chart whose axis does not start at zero. A bar's length tells the reader its size. Suppose (made-up numbers) gripper A succeeds in 92% of trials and gripper B in 94%. If the vertical axis starts at 91%, bar A is 1 unit tall and bar B is 3 units tall. B looks three times better, when the real difference is 2 percentage points. Bar charts should start at zero. Line and scatter plots may zoom in, because they encode values by position rather than length, but the axis labels must make the zoom obvious.

2. Cherry-picked ranges. Showing only the week when a robot performed well, or cutting the time axis just before a failure, can reverse the story. Show the whole range, or explain why you chose a window.

3. Hidden sample sizes. A bar for "3 trials" and a bar for "300 trials" look identical. Put n on the chart or in the caption.

4. Missing or unlabelled error bars. Without them, a reader cannot tell whether a difference is larger than the noise.

5. Two different vertical axes. Plotting two quantities with a left and a right axis lets the author slide and stretch either one until the lines appear to move together. Prefer two separate plots that share the horizontal axis.

6. Smoothing or joining points that should not be joined. Drawing a smooth curve through five scattered points suggests far more knowledge than five points provide. Show the points; add a fitted line only if you explain the model.

7. Decoration that distorts. 3D bars, tilted pie charts and pictures scaled in both width and height all make sizes hard to judge.

A checklist before you share a plot

  • Is this the right type of plot for the question?
  • Are both axes labelled with quantity and units?
  • Does a bar chart start at zero?
  • Are n and the meaning of any error bars stated?
  • Would someone who only saw the plot draw the same conclusion you did from the full data?

Recap

Plot your data before trusting summaries. Match the plot to the question: line for change over an ordered axis, scatter for relationships, histogram for distributions, bars or dot plots for categories. Label everything, show uncertainty and sample sizes, start bar charts at zero, and avoid tricks that make a small or uncertain effect look large.

Project

Redesign a misleading chart

Find a chart in a newspaper, an advert or a website that you think is misleading, or invent one using the made-up gripper success rates from this lesson.

  1. Sketch the original on paper and list every problem you can find, using the seven tricks above.
  2. Sketch an honest version that shows the same data. Label the axes with units and state n.
  3. Using Python, print a text bar chart of the same values twice: once with bar lengths proportional to the values, and once proportional to (value − 91). Compare how the difference looks.
  4. Optional: if you have matplotlib available, produce both versions as proper plots.

Deliverables

  • A sketch of the original chart with its problems listed
  • A sketch or plot of an honest version
  • A short Python script that prints both text bar charts

Knowledge check

Check your understanding

  1. 1. Which plot best shows how a single sensor's readings are distributed?
  2. 2. Success rates of 92% and 94% are drawn as bars on an axis starting at 91%. How many times taller does the 94% bar look?
  3. 3. You have 6 trials per condition. Why might a dot plot be better than a bar chart of means?
  4. 4. Why is changing a histogram's bin width something you should report?

Go further

Visualising data honestly — Computational Engineering — Tactiverge