TactivergeLite

Lite / Intelligent Robotic Systems / Week 8

Choose the plot that answers the question

Same sensor log, three questions: is it drifting? How noisy is it? Is it related to temperature? Why should those be three different charts?

About 35 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

A chart is an answer to a question. Pick the wrong kind and the answer is hidden, however good the data. Engineers choose the plot after writing the question down, and label it so a reader can check it without asking them.

Predict

You want to see how a motor's temperature changed during a 30-minute test. Which plot?

  1. A pie chart of temperatures
  2. A line plot of temperature against time
  3. A histogram of temperatures
  4. A bar chart of the average
Guess first, then reveal

A line plot against time: the question is about change over time, so time goes on the x-axis. A histogram would show how often each temperature occurred but hide when; an average hides everything.

Discover

Switch between bars and a line. Which form makes the change over the year easiest to read? Which makes the before/after comparison easiest? Then turn on the error bars: what extra question can you now answer?

What the interactive shows (text version)

The chart critique shows monthly conveyor jams as bars or as a line. A line shows the change across the year most clearly; bars from zero make the before and after levels easy to compare; error bars show the day-to-day spread so the size of the change can be judged against it.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Watch how the axis labels, title and legend are added: those lines are what turn a picture into evidence.

Makes and labels a first line plot in Python, including titles, axis labels and legends.

“Matplotlib Tutorial (Part 1): Creating and Customizing Our First Plots” by Corey Schafer (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Question first, plot second

Change over time → line (time on x). Relationship between two measurements → scatter. Spread of one measurement → histogram (or box plot). Comparing a few groups → bars (from zero) or points with error bars. Parts of a whole → a stacked bar is usually clearer than a pie.

Label like a datasheet

Every axis gets a quantity and a unit: 'Motor temperature (°C)', 'Time (s)'. Add a title that states the finding or the question, a legend if there is more than one series, and a note of where the data came from and how many samples.

Show the data, not just a summary

Plot the individual readings when you can, and add the mean on top. A single average bar hides spread, outliers and drift, which are often exactly what an engineer needs to see.

Explain it another way

Intuitive

A map answers 'where?', a clock answers 'when?'. Charts are the same: each kind answers a different kind of question well.

Technical

In matplotlib, fig, ax = plt.subplots() then ax.plot(x, y) for lines, ax.scatter for relationships, ax.hist for distributions and ax.bar for comparisons; ax.set_xlabel, ax.set_ylabel and ax.set_title label it; fig.savefig("plot.png", dpi=150) saves it.

Applied

Engineering test reports usually standardise their charts: time series with units on both axes, the same colours for the same sensor in every figure, and the number of samples in each caption.

Worked example 1

A fully labelled line plot of a motor temperature log.

import matplotlib
matplotlib.use("Agg")                    # draw to a file, no window needed
import matplotlib.pyplot as plt

time_s = [0, 60, 120, 180, 240, 300, 360]
temp_c = [21.0, 26.5, 31.2, 34.8, 37.1, 38.4, 39.0]

fig, ax = plt.subplots(figsize=(6, 3.5))
ax.plot(time_s, temp_c, marker="o")
ax.set_xlabel("Time since start (s)")
ax.set_ylabel("Motor case temperature (°C)")
ax.set_title("Temperature levels off near 39 °C (7 readings, 1 per minute)")
ax.set_ylim(0, 45)
ax.grid(True, alpha=0.3)
fig.tight_layout()
fig.savefig("motor_temp.png", dpi=150)

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 1. Does a servo's current draw rise with the load on its arm? You have 40 (load, current) pairs. Which plot?
Practice 2. How noisy is a gyro at rest? You have 5,000 readings. Which plot shows the spread best?
Practice 3. Which y-axis label is best?

Apply it

Take a sensor log you have (or the motor test CSV from week 3). Write three questions about it and make one correctly chosen, fully labelled plot for each. Under each, write one sentence answering its question.

Reflect

Which plot type do you overuse, and which question does it fail to answer?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Speed from position, distance from speed: calculus on samplesCharts that lie without a single false number →