Compare Paired Measurements
Keep matching values from each observation together, then describe the visible relationship without adding a cause the plot cannot establish.
A scatter plot compares two values that belong to the same observation. Its central requirement is not sorting or connecting points. It is preserving each pair.
Build Pairs from Matching Positions
Use the recurring raw table and calibration:
For the North sensor, compare each raw reading with its calibrated value:
raw: [2. 4. 6.]
calibrated: [2. 3. 4.]
(2.0, 2.0)
(4.0, 3.0)
(6.0, 4.0)
Each pair comes from one row in the original table:
| Observation | Raw North | Calibrated North | Scatter point |
|---|---|---|---|
| 0 | 2.0 | 2.0 | (2.0, 2.0) |
| 1 | 4.0 | 3.0 | (4.0, 3.0) |
| 2 | 6.0 | 4.0 | (6.0, 4.0) |
The observation index is not drawn as an axis, but it still determines which
two values belong together. Both arrays have shape (3,), which is necessary
but not sufficient: their positions must also refer to the same observations
in the same order.
Q1. Trace one paired point
Observation 1 has raw North reading 4.0 and calibrated North reading 3.0.
Which point represents it when raw is horizontal and calibrated is vertical?
Select one choice, then check.
HintUse the axis order
A scatter coordinate is (horizontal, vertical). Here that means
(raw, calibrated).
SolutionThe point is (4.0, 3.0)
The horizontal raw coordinate is 4.0, and the vertical calibrated
coordinate from the same observation is 3.0.
Draw the Paired Values
ax.scatter(horizontal, vertical) places one mark for each pair of positions:
Compare raw and calibrated readings for one sensor
Three scatter points preserve observation identity between raw and calibrated North-sensor readings. A dashed equality line marks where a reading would be unchanged.
Ready to run.
The scatter marks are not connected because horizontal order is not the relationship this view is meant to preserve. The point positions compare raw and calibrated values. Observation identity remains in the paired array positions and the printed table.
The dashed line shows . In this plot that line has a stated meaning: a
point on it has an unchanged calibrated value. The first point (2, 2) lies on
the line. The points (4, 3) and (6, 4) lie below it because their calibrated
values are smaller than their raw values.
A reference line should not be added merely to fill the plot. It belongs here because equality answers a real comparison question. If equal horizontal and vertical values had no useful interpretation, the line would be decoration and should be omitted.
Q2. Create a paired scatter plot
Complete the scatter plot with raw readings on the horizontal axis and the matching calibrated readings on the vertical axis. Add the equality reference and label both quantities.
Editable Python
Ready to run.
HintKeep both arrays in their original order
Call ax.scatter(raw_north, calibrated_north). Plot equality_limits against
itself with linestyle="--", then add the labels and title.
SolutionPlot corresponding positions together
The three printed pairs are the exact coordinates behind the scatter marks.
Do Not Break the Pairing
Sorting one array independently changes which values are paired. Consider a different calibrated order:
These positions preserve the observation pairs (6, 4), (2, 2), and
(4, 3). Sorting only the raw array creates:
(2.0, 4.0)
(4.0, 2.0)
(6.0, 3.0)
All shapes still match, and Matplotlib can draw the result. The points are wrong because values from different observations have been joined. If an order change is required, compute one ordering of observation positions and apply it to both arrays.
The three correct points also lie exactly on the known calibration rule
. That agreement is expected because calibrated was computed from
raw with that formula. It is a check of the program, not evidence that three
independent observations revealed a new scientific law.
Q3. Diagnose a broken pairing
A program independently sorts the raw values but leaves the calibrated values
in their original order before calling scatter. What should we conclude?
Select one choice, then check.
HintTrack the observation behind each value
Equal shapes guarantee the number of coordinates. They do not guarantee that corresponding positions still name the same record.
SolutionApply one ordering to both arrays
Sorting only one side breaks observation identity, although the plotting call still runs. Preserve the original order or use one index order to rearrange both raw and calibrated arrays together.
A scatter plot places one paired value on each axis. Preserve record identity, print or tabulate the exact pairs, and add a reference line only when it has a named interpretation. Describe the visible relationship cautiously: a plot can check a known computation without proving a new cause or general rule. The next lesson asks what remains when observation order is deliberately set aside to inspect a distribution.