Why Construct a Scatterplot?
A scatterplot displays the paired values of two numeric variables. Each point represents one observation: its horizontal position shows the value of one variable, and its vertical position shows the value of the other. This makes a scatterplot useful for checking whether the variables appear to move together and for noticing features such as clusters, gaps, or points that warrant a closer look.
A plot is only as clear as its setup and interpretation. The variables must be assigned to the correct axes, the axis labels must state what is measured, and the reader must be able to tell what each point represents. A visible association is not evidence, by itself, that changing one variable causes a change in the other. These plotting and interpretation skills are aligned with the SOA Exam PA (Predictive Analytics) syllabus.
Building a Base R Scatterplot
In base R, the usual function is plot(x, y). The first argument supplies the horizontal values and the second supplies the vertical values. For data stored in a data frame named dat, a call such as plot(dat$exposure, dat$cost) plots cost against exposure: exposure is on the horizontal axis, cost on the vertical axis.
A useful plot should identify the variables and their units. The arguments xlab and ylab set the axis labels, and main sets a title. The argument pch selects the plotting symbol; for example, pch = 19 uses a filled circle. The argument col sets its color. Unless another plot type is requested, plot(x, y) draws points.
For a reproducible display, set both axis limits when the ranges matter and specify how R handles the ends of the axes. In the examples below, xaxs = "i" and yaxs = "i" make the plotting limits coincide with the stated xlim and ylim. This avoids R’s default axis expansion when we calculate where points fall relative to those limits.
This position formula follows because the axis maps its lower endpoint to 0 and its upper endpoint to 1 by a linear rescaling. If \(x=a\), the expression is 0; if \(x=b\), it is 1. A value partway between them is assigned the same fraction of the plotting width: the distance \(x-a\) divided by the full range \(b-a\). The vertical mapping follows in the same way.
There is an important base R detail: the default setting is xaxs = "r" and yaxs = "r". R expands each axis range by about 4% at each end. Thus, with default settings, the limits visible in the plotting region are not generally the requested xlim and ylim endpoints. If the requested horizontal limits are 0 and 6, for instance, the expanded limits are approximately -0.24 and 6.24. The point \(x=1\) is then at \((1-(-0.24))/(6.24-(-0.24))=1.24/6.48\), or approximately 0.191 of the plotting width—not \(1/6\). Use the “i” settings when the limits should match the stated endpoints, or account for the expanded endpoints when describing positions.
Choose two numeric measurements and confirm that each x-value and y-value refer to the same observation.
Put the intended explanatory or comparison variable on the horizontal axis, select limits that show the relevant values, and decide whether to use exact limits with “i” axis styles.
Write informative axis labels, including units when applicable, and add a title that states what is being compared.
Summarize the overall direction and visual strength; note any visible clusters, gaps, or unusual points. Treat these as features to investigate, not explanations or proof of causation.
Reading Direction and Visual Strength
A pattern has a positive direction when larger values of one variable tend to appear with larger values of the other. It has a negative direction when larger values of one tend to appear with smaller values of the other. If neither tendency is clear, describe the direction as unclear rather than forcing a label.
Visual strength concerns how tightly the points follow a recognizable pattern. A clear direction with points lying relatively close to that pattern looks stronger than a direction accompanied by broad scatter. This is a qualitative description of the displayed points, not a guarantee about a larger population. The same plot can also contain a general direction alongside a local feature that deserves attention.
Worked Example: Clear Labels and a Positive Pattern
A fictional service team records the number of staff-hours assigned to each of five maintenance jobs and the number of faults found during inspection. The paired data are \((1,3), (2,5), (3,6), (4,8), (5,9)\), where the first value is staff-hours and the second is faults. Construct a labelled scatterplot and describe its pattern.
Method. Put staff-hours on the horizontal axis and faults on the vertical axis. Choose horizontal limits 0 to 6 and vertical limits 0 to 10 so every observation lies inside the plotting region. Use exact axis limits by specifying xaxs = "i" and yaxs = "i".
The base R call is plot(c(1, 2, 3, 4, 5), c(3, 5, 6, 8, 9), xlim = c(0, 6), ylim = c(0, 10), xaxs = "i", yaxs = "i", xlab = "Staff-hours", ylab = "Faults found", main = "Inspection faults by staff-hours", pch = 19).
Check the plotted positions. With the exact limits, the horizontal position is \(x/6\) and the vertical position is \(y/10\). The five normalized positions are \((1/6,3/10)=(0.167,0.300)\), \((2/6,5/10)=(0.333,0.500)\), \((3/6,6/10)=(0.500,0.600)\), \((4/6,8/10)=(0.667,0.800)\), and \((5/6,9/10)=(0.833,0.900)\). Positions are rounded to three decimals.
Interpretation and check. The points tend to rise from left to right, so the displayed association is positive. They follow a fairly consistent increasing pattern, so the visual association is reasonably strong in this small set. All values are within the selected limits. This does not show that assigning more staff-hours causes more faults; job difficulty or other factors could affect both measurements.
Common mistake avoided. Using the requested limits to calculate positions while leaving the default “r” axis style in place would give incorrect normalized positions. Here the “i” settings make 0 and 6, and 0 and 10, the actual plotting endpoints.
Gaps and Points to Investigate
A gap is a region of the display with no observed points. A cluster is a group of points that appear relatively close together, often with a visible gap separating them from another group. These are descriptions of the plotted sample. A gap does not establish that intermediate values are impossible, and a cluster does not by itself identify why the observations differ.
A point that sits away from the main pattern is a reason to check the record and its context. It might reflect a data-entry or measurement issue, a genuine unusual observation, or a feature of the relationship that deserves further analysis. Do not delete a point just because it is inconvenient, and do not label it an error based on the plot alone.
Worked Example: A Declining Pattern With a Point to Check
A hypothetical equipment survey records operating years and a vibration reading for six devices. The paired values are \((0,18), (1,17), (2,15), (3,13), (4,12), (5,6)\). Construct the plot and identify what a reviewer should investigate.
Method. Use operating years horizontally and vibration vertically. Set the limits to 0 through 6 years and 0 through 20 units, with exact axis endpoints. The R command is plot(c(0, 1, 2, 3, 4, 5), c(18, 17, 15, 13, 12, 6), xlim = c(0, 6), ylim = c(0, 20), xaxs = "i", yaxs = "i", xlab = "Operating years", ylab = "Vibration reading (units)", main = "Vibration by operating years", pch = 19).
Check the coordinates. The normalized positions use \(u=x/6\) and \(v=y/20\). In the original order, they are \((0.000,0.900)\), \((0.167,0.850)\), \((0.333,0.750)\), \((0.500,0.650)\), \((0.667,0.600)\), and \((0.833,0.300)\). For example, the last point has \(u=5/6=0.833\) and \(v=6/20=0.300\). Positions are rounded to three decimals.
Interpretation and check. The readings generally decline as operating years increase, which is a negative direction. The last point is separated vertically from the preceding values: the earlier readings fall from 18 to 12, while the final reading is 6. Check that device’s recorded age and reading, the measurement process, and any relevant context before deciding how to handle it. The plot alone cannot determine whether the observation is wrong or explain why the reading is lower.
Common mistake avoided. Do not automatically remove the final point or claim that age caused the change. A scatterplot flags a feature for investigation; it does not establish an error or a causal explanation.
Worked Example: Recognizing Two Clusters and a Gap
A fictional laboratory records the calibration setting and output reading for six test runs on an instrument. The data are \((1,2), (2,3), (3,4), (8,8), (9,9), (10,10)\). Plot the values and describe the visible structure without assigning an unsupported explanation.
Method. Put calibration setting on the horizontal axis and output reading on the vertical axis. Use limits from 0 to 12 on both axes. The R call is plot(c(1, 2, 3, 8, 9, 10), c(2, 3, 4, 8, 9, 10), xlim = c(0, 12), ylim = c(0, 12), xaxs = "i", yaxs = "i", xlab = "Calibration setting", ylab = "Output reading", main = "Instrument output by calibration setting", pch = 19).
Check the coordinates. Both normalized coordinates are the corresponding value divided by 12. The points are \((0.083,0.167)\), \((0.167,0.250)\), \((0.250,0.333)\), \((0.667,0.667)\), \((0.750,0.750)\), and \((0.833,0.833)\). For instance, the fourth point has \(u=8/12=0.667\) and \(v=8/12=0.667\). Positions are rounded to three decimals.
Interpretation and check. The points form a lower-setting cluster at horizontal values 1 to 3 and an upper-setting cluster at 8 to 10, with no observed settings from 4 through 7. Each cluster rises from left to right. The visible gap is a feature of these six runs; it does not prove that settings in the gap cannot occur or reveal why the runs fall into these groups. Confirm that the values and units were recorded as intended before drawing further conclusions.
Common mistake avoided. Do not assume that the two clusters represent known populations or different operating conditions unless the study information supports that interpretation.
Axis Choices and Responsible Interpretation
Axis limits determine which values are visible and how much of the plotting area the points occupy. Limits that are too narrow can omit observations; limits that are unnecessarily wide can compress the point pattern. Check the data range before setting limits, and do not use an axis range that silently excludes values relevant to the question. When the exact endpoints matter, make the axis style explicit rather than assuming the requested limits are the plotting-region limits.
A disciplined description stays close to what is visible. State the direction, characterize the visual strength, and point out visible clusters, gaps, or unusual points. Then separate those observations from explanations. For example, “higher settings tend to accompany higher readings in this sample” describes an association. “Increasing the setting causes the reading to rise” is a causal claim and requires evidence beyond the scatterplot.
- Check the pairing. Each plotted point must combine values from one observation.
- Check the labels. Name the measured variables and include units where relevant.
- Check the axis settings. Know whether the plotting region uses exact or expanded limits.
- Check unusual features in context. A point or gap is a prompt to investigate, not a verdict.
- Do not overstate the result. The plot describes observed association; it does not establish causation.
Check Your Understanding
For each problem, consider both the R setup and what the plotted points can support.
- A hypothetical analyst records training hours \(2, 4, 6\) and paired assessment scores \(5, 7, 8\). Name the horizontal and vertical variables, give a base R call with clear labels and exact limits from 0 to 10 on both axes, and state the direction. (Answer: Training hours go on the horizontal axis and scores on the vertical axis; use plot(c(2, 4, 6), c(5, 7, 8), xlim = c(0, 10), ylim = c(0, 10), xaxs = "i", yaxs = "i", xlab = "Training hours", ylab = "Assessment score"); the visible direction is positive.)
- A plot uses xlim = c(0, 8), ylim = c(0, 20), xaxs = "i", and yaxs = "i". Find the normalized position of the point \((2,15)\), rounding to three decimals. (Answer: \((2/8,15/20)=(0.250,0.750)\).)
- A call requests xlim = c(0, 6) but leaves the default xaxs setting. What approximate horizontal plotting limits does base R use, and what is the normalized horizontal position of \(x=1\), rounded to three decimals? (Answer: Approximately \(-0.24\) to \(6.24\); \((1+0.24)/6.48 \approx 0.191\).)
- A hypothetical set of readings generally rises as the corresponding machine settings rise, but one point is far below the rest. State the direction, one suitable next step, and one conclusion that the plot alone does not justify. (Answer: The visible direction is positive; check the unusual point’s record and context; the plot alone does not justify calling it an error or claiming that the setting caused the readings.)
- Six paired observations have x-values \(1,2,3,8,9,10\), with corresponding y-values \(2,3,4,8,9,10\). Using axis limits 0 to 12 on both axes and exact axis styles, describe the visible grouping and gap, and state what should not be inferred from them alone. (Answer: There are two visible clusters, at x-values 1–3 and 8–10, with a gap between them; the plot alone does not establish why the clusters occur or that intermediate x-values are impossible.)