Scatter plot and regression line

A scatter plot for two quantitative variables, with the regression line, the correlation and its confidence interval, the percentage of explained variance, the equation of the line with standard errors – and diagnosis of outlying and influential observations. It is possible to color by group (a line for each group) and to add confidence and prediction bands. The output: a chart with a figure note, tables, report sentences in English, "Reading the result", Word and SPSS syntax.

Calculator

Loading the data

Drag an Excel file or an SPSS file (.sav) here, or click to choose
In the site's standard template: row = participant, column = variable, first row = headers. CSV is also accepted.
The two variables for the chart are numeric columns – scale scores, age, hours; a grouping variable (optional) – a column with 2-7 values, such as group or sex. An ID column is detected and neutralized – and is used to identify points on hover.
Just want to try it out? Download a sample data file (512 participants from a community resilience survey: age group, religion, region, education, income and five 1-5 scales, with a legend): English example
or

Paste columns directly from the spreadsheet (including the header row) – select in Excel, copy, and paste here (comma-separated values also work, like the Anscombe quartet in the guide):

A
B
C
D
E
F
You can also just paste – the data will be loaded and displayed automatically.

Variable selection

Guide

When is a scatter plot used?

A scatter graph (also called a scatter diagram or scatter plot) shows the relationship between two quantitative variables. Each point is one participant: its position is determined by their value on the two variables – one variable on the X axis, the other on the Y axis, and each participant is their (x, y) pair. The chart is the first step before computing a correlation, because it reveals things that the number alone hides – a nonlinear relationship, outlying observations, or separate groups within the sample. And even before any computation, a look at the cloud of points shows the three properties that the correlation coefficient will later summarize in a single number: direction – rising or falling; form – a straight line, a curve, or nothing at all; and strength – how closely the points cluster around that form (Gravetter & Wallnau, 2017, pp. 487-488; Pallant, 2020, pp. 153-154). Of the three, the number summarizes only the first and third well – and the second it simply assumes in advance.

The article that made the scatter plot mandatory opens with three beliefs that almost all of us were brought up on, and all of them are wrong: that computations are exact and graphs are "rough"; that for every kind of data there is one correct computation; and that complicated computations are a virtue, whereas looking at the data is cheating (Anscombe, 1973, p. 17). The computer, writes Anscombe, should produce both computations and graphs – and both should be studied. And when Y is plotted against X before any computation, one of five things will happen: the points lie almost on a straight line; they lie on a smooth curve that is not a straight line; they are scattered with no relation to X; something in between; or – the most interesting case of all – most of them cluster around a line or a curve, and a few are very far away. In the last case there is an effect to see, but the usual regression computations may miss it (ibid.). The second can sometimes be brought back to the first by a transformation of the X or Y scale; and in the fifth, always start by checking that the outlying values were entered correctly – and if they are real, set them aside for special study, which "may prove very rewarding".

Hence the simple rule of Gelman & Hill (2007, p. 554): alongside every regression you run – draw a scatter plot; and not only of the data, but also of the model fitted to them, because "a table of coefficients does not give the feel that a graph gives" (ibid., p. 548). And two remarks of theirs on which graph: a scatterplot matrix of all pairs (see Extensions) is like regressing every variable on every variable – useful, but more is learned from carefully chosen graphs; and when the two variables have a temporal or causal order, the "before" goes on the X axis and the "after" on the Y axis (ibid., p. 553).

How to read the chart: the regression line and R²

The regression line is the straight line that minimizes the sum of the squared vertical distances from the points to the line – "the best line" in this sense only, and not in the sense that it passes closest to each point separately. Its slope describes by how many units variable Y is expected to change for an increase of one unit in X: a positive slope describes a rising relationship, a negative slope – a falling relationship, and a slope close to zero – the absence of a linear relationship.

R² (the coefficient of determination) expresses the proportion of the variance in variable Y that the regression line "explains" by means of X. Its value is always between 0 and 1 (or 0% to 100%), and it does not depend on the direction of the relationship: R² = .25 means that 25% of the variance in Y is explained by X, whether the relationship is rising or falling. Its relationship to the Pearson coefficient is simple – R² is the square of r – so to get back from R² to r, take the square root and add the sign according to the direction of the regression line (rising = positive, falling = negative). Hence also the effect-size scale: an R² of .01 is a small relationship, .09 – medium, and .25 and above – large (Gravetter & Wallnau, 2017, p. 501) – exactly the thresholds r = .1 / .3 / .5 by which the calculator describes the strength of the relationship in words. And since squaring erases the sign, a correlation of +.80 and a correlation of −.80 are equally consistent relationships – sign and strength are independent of each other (ibid., p. 489).

Slope is not strength. A common mistake is to read a steep line as a "strong relationship" and a gentle line as a "weak relationship". The strength of the relationship is how closely the points cluster around the line – not how steep the line is. The slope describes by how many units Y changes for each unit of X, so it depends on the units of measurement: exactly the same data will give a steep line if Y is measured in points and a gentle one if it is measured in hundreds of points – and an identical correlation in both cases. In the formulation of Cohen (1988, pp. 75, 77): r is itself a slope – the slope of the line when both variables have been standardized to the same variance – whereas b is the same slope in raw units, b = r·sY/sX; and when the units have a meaning of their own (shekels, years, test points) it is usually better to report b, which also remains stable when the spread of X changes between samples. In the table the calculator produces, the two are explicitly separated: r and R² measure strength, b measures slope. This can also be seen in the sample data: self-efficacy×trust and leadership×readiness are two pairs with an almost identical slope (0.687 and 0.716) but a different R² (.545 versus .522) – and the larger slope is actually in the weaker pair.

And what happens when the axes are swapped. The correlation does not know which is X and which is Y – r is symmetric, and the same value is obtained in both arrangements. The regression line very much does know: the line of Y on X minimizes vertical distances, and the line of X on Y minimizes horizontal distances, and these are two different lines that coincide only when the correlation is perfect. The two slope coefficients also differ – they are equal to each other only when the standard deviations of the two variables are equal – and so the scatter plot itself is not symmetric either: the same data look different when the axes are swapped (Cohen, Cohen, West & Aiken, 2003, p. 110). In the sample data: trust on self-efficacy gives b = 0.687; self-efficacy on trust gives b = 0.793 – and the same r = .738 in both cases. This can be checked in the calculator with one click, by swapping the two variables. That is why the placement – predictor on X, outcome on Y – is a decision to be made before the computation and reported, not a matter of convenience.

The words are a convention, the number is the finding. The calculator describes the strength in words by Cohen's (1988) thresholds of .1 / .3 / .5 – accepted in the social sciences, but not the only ones. Some textbooks use a five-level scale: up to .1 no relationship, .1-.3 weak, .3-.5 moderate, .5-.7 high, and above .7 very high. The correlation of .738 in the sample data is "strong" by one scale and "very high" by the other – so always report the number, and give the verbal description as an addition. It is worth knowing that Cohen himself explicitly proposed the thresholds as a convention "for use when no better basis is available", and invited every field to set other definitions for itself (1988, p. 79). Behind each threshold there is a rationale: .10 is a relationship not visible to ordinary observation, but many of the relationships the "soft" sciences pursue are of this order of magnitude (p. 79); .30 – the "middle of the range" of correlations between different psychological variables, and a relationship that a "reasonably sensitive observer" can already see with the naked eye (p. 80); and .50 – "about as high as they come": the practical limit of correlations between different variables in personality, educational and counseling psychology, such as the correlation between IQ and school grades (pp. 80-81). Above it, Cohen notes, one usually finds only reliability coefficients (p. 78) – so a correlation like .74 between two questionnaire scales, as in the sample data, is especially high by these standards, and it is worth asking whether the two scales partly measure the same thing. And if you want a number that directly measures the spread around the line – "how closely the points cluster around it" – that is the standard error of the estimate: the standard deviation of the residuals, in units of Y; the smaller it is, the more accurate the prediction (Cohen, Cohen, West & Aiken, 2003, pp. 40-41). It is not in the table on this page, but it appears in the Model Summary table of the regression procedure (see From the chart to regression).

And when Spearman's correlation. The table the calculator produces shows, alongside Pearson, also Spearman's correlation, computed on the ranks of the values and not on the values themselves. Gravetter & Wallnau (2017, pp. 510-511) list two situations in which it is used: when the variables are measured on an ordinal scale (rankings), and when a consistent relationship in one direction is expected that is not necessarily a straight line – for example practice and performance, which improves with every practice session but at a diminishing rate; Spearman measures the consistency of the relationship regardless of its form, because when the relationship is consistent the ranks line up on a straight line even if the values do not. In the language of the scatter plot: Spearman asks whether the cloud rises (or falls) consistently, not necessarily in a straight line, so it is less sensitive to a single outlying observation and to a curve that does not change the direction. Comparing the two rows in the table is a quick check: when the two are close, the relationship is approximately linear and without significant outliers; when Spearman is much larger than Pearson, there is something in the cloud – a curve or a distant point – that is worth going back and looking at.

And when the relationship is not a straight line. A low correlation does not prove that there is no relationship: there may be a strong and consistent relationship that is not linear, which a straight line and the Pearson coefficient simply do not see. The classic example from psychology is the relationship between anxiety and performance – up to a certain level of anxiety performance improves, and beyond it it declines; in the scatter plot this is an inverted U shape, and the Pearson correlation may approach zero even though the relationship is plain to see – Pearson measures straight-line relationships only, and other forms have other measures (Gravetter & Wallnau, 2017, p. 488; Pallant, 2020, p. 153). This is another reason always to start from the chart – see also the Anscombe quartet on the correlations page.

The quartet – try it in the calculator. The four invented datasets of Anscombe (1973, p. 19), eleven pairs each, give exactly the same standard output: n = 11, mean of X 9.0, mean of Y 7.5, regression line Ŷ = 3 + 0.5·X, R² = .667 – and yet only the first is what most people imagine when they see these numbers: the second is a smooth curve, the third a perfect straight line with one deviating point, and the fourth ten points at the same X and one point that alone determines the slope. This can be seen in the calculator on the page: copy the following block into the paste tab, and select one after another x with y1, y2, y3, and then x4 with y4:

x,y1,y2,y3,x4,y4
10,8.04,9.14,7.46,8,6.58
8,6.95,8.14,6.77,8,5.76
13,7.58,8.74,12.74,8,7.71
9,8.81,8.77,7.11,8,8.84
11,8.33,9.26,7.81,8,8.47
14,9.96,8.10,8.84,8,7.04
6,7.24,6.13,6.08,8,5.25
4,4.26,3.10,5.39,19,12.50
12,10.84,9.13,8.15,8,5.56
7,4.82,7.26,6.42,8,7.91
5,5.68,4.74,5.73,8,6.89

Note two rows in the table. r and R² are identical in all four (.816, .667; rounding differences in the third digit) – this is exactly Anscombe's point. But Spearman's correlation is very different: .82, .69, .99 and .50 – in the third dataset Spearman is much higher than Pearson (a perfect line with one outlier), and in the fourth it is much lower (ten tied ranks and one point) – exactly the sign described above in "And when Spearman's correlation". The numbers, if you know where to look, do hint; but the graph simply shows.

And when the cloud splits into clumps. A cloud that looks like two or three separate clumps, arranged diagonally, is a warning sign of a third variable. The example of Gravetter & Wallnau (2017, pp. 497, 502-503): a strong positive correlation was found between the number of churches and the number of crimes in cities – not because prayer breeds crime, but because both grow with the size of the city; within each size group, the relationship disappears. In the scatter plot this looks like clumps by city size, each of which on its own has no trend. When this is suspected, color or split the graph by the third variable (see Overlay Scatter and Panel by in Extensions), or compute a partial correlation – on the correlations page.

And what the line tells about the extreme participants. When the correlation is not perfect, the extreme points on X are not the extreme ones on Y: the participants highest on one variable tend to be high – but less so – on the other variable, and likewise the lowest. This is regression to the mean (regression toward the mean; Gravetter & Wallnau, 2017, pp. 501-502), and it is the reason the regression line is always gentler than the diagonal of the cloud. There is no force pulling here – it is a statistical fact that follows from the relationship being imperfect; but it explains, for example, why the "player of the year" in their first season disappoints in the second, and why whoever got the highest score on test A will usually be only above average on test B. Gelman, Hill & Vehtari (2020, pp. 87-90) also resolve the paradox that troubles many: if daughters of tall mothers are shorter than them on average, won't we all be the same height in a few generations? No – because the prediction regresses to the mean, but the observation is not the prediction: the prediction error adds back exactly the spread that the regression removes, and the variance across generations stays constant. More dangerous is the so-called regression fallacy – attributing a cause to regression. The example of Tversky and Kahneman, which they cite: flight instructors who noticed that after praise for a successful maneuver the next performance was worse, and after a reprimand – better, and concluded that praise is harmful; in fact an excellent maneuver is also a result of luck, and a decline is expected after it regardless of the instructor's response. The same with students who "slacked off" after a high midterm score: in a simulation in which the scores are true ability plus pure noise, with no motivation at all, exactly the same pattern is obtained. A scatter plot of "before" against "after" – with a regression line gentler than the diagonal – is exactly the situation in which this is worth remembering.

And such a graph has a simple visual aid, which the calculator on the page does not have and which can be added in SPSS or R: Gelman & Hill (2007, p. 556) recommend drawing a "default line" – a horizontal line at zero, or, in a before-versus-after graph in the same units, the diagonal y = x that marks equality. Once the diagonal is on the graph, regression to the mean can be seen by eye: those who were high "before" sit mostly below the diagonal, those who were low – above it, and the regression line crosses the diagonal at the mean. And in the same context – when both axes measure the same thing in the same units, draw the graph square and with the same scale on both axes, even if large parts of it remain empty; and when the variables are different, specifically not square, so as not to implicitly convey an equality that does not exist (ibid.).

Three looks, in this order. Pallant (2020, pp. 156-157) suggests reading every scatter plot in three fixed stages, before computing anything:

1. Outliers

Are there points sitting on their own – very high, very low, or far from the cloud? Each one is worth checking: was it entered correctly? A careless answer? Or a real value of an exceptional person. In the calculator on this page, hovering over a point shows its values.

2. Shape of the cloud

Points scattered in all directions, like a blob – a very weak relationship. Points that cluster in a narrow cigar shape around an imaginary line – a strong relationship. And if a curved line describes the cloud better than a straight line – Pearson is not the right measure.

3. Direction

If you drew a line through the cloud – which way would it point? Rising from left to right – a positive relationship; falling – negative. Only after these three looks, when the relationship is approximately linear and the cloud is "cigar-shaped" and even, compute the correlation coefficient.

A rule of thumb for the envelope. Gravetter & Wallnau (2017, p. 489) suggest a way to estimate r by eye: draw an envelope around the points – the narrowest closed line that contains all of them. An envelope shaped like a football is a correlation of about .7; a fatter envelope – a correlation closer to 0; a narrower envelope – closer to 1. With discrete data such as Likert scales, where one point hides dozens of participants (see above), this estimate is misleading – there, rely on the number.

The line the eye draws is not the regression line. When students are asked to draw the regression line by hand on a cloud of points, they almost always draw the long axis of the cloud – the line that "passes closest" to all the points (in statistical language: the principal component line). But the regression line minimizes vertical distances only, and it is always gentler: in standardized variables with a correlation of .5 its slope is exactly half the slope of the cloud's axis (Gelman, Hill & Vehtari, 2020, pp. 187-188). And despite appearances, it is the right line for prediction: at the left end of the cloud all the points sit above the long axis – it predicts too low for low X values and too high for high ones – whereas the regression line passes through the mean of Y at every value of X. This is also the geometric explanation of the regression to the mean described above.

The line is a model, and the model predicts. The regression line is the simplest form of what Field (2024, section 9.2) calls "the linear model": Ŷ = b0 + b1X. The two parameters are exactly the last two rows in the table the calculator produces – the intercept b0 (a in the table): the expected value of Y when X = 0; and the slope b1 (b in the table): the expected change in Y for each increase of one unit in X. The hat over the Y is a reminder that this is what is called a predicted value, not an observed value: plug in a value of X and get the Y the model predicts. In the sample data, for example, for a respondent whose self-efficacy level is 4.0 the model predicts trust of 1.159 + 0.687 × 4.0 ≈ 3.91. This prediction is not exact for every participant – the difference between the observed value and the predicted value is the so-called residual, and the line is chosen so that the sum of the squared residuals is the smallest possible (the method of least squares, Field, 2024, section 9.2.4). Three simple facts about this line help read any chart (Gravetter & Wallnau, 2017, Section 16.1): it always passes through the point (mean of X, mean of Y); the sign of its slope is the sign of the correlation; and when the correlation is zero it is a horizontal line at the mean of Y – exactly the "no relationship" model in the next paragraph.

Where R² comes from, and what test is behind the p. To know whether the model is good, it is compared with the simplest model there is – "no relationship": predicting the mean of Y for every participant, whatever X may be. The sum of the squared distances of the observations from the mean (SST) is the amount of variance to be explained; the sum of the squared distances from the regression line (SSR) is what remains unexplained after fitting the line; and the difference between them (SSM) is the improvement the line brought. R² is simply the ratio SSM / SST – the part of the variance the model explains out of what there was to explain (Field, 2024, Section 9.2.4). On the same sums of squares the F test is built, which asks whether the model is significantly better than the mean; and on the slope the t test is built with n − 2 degrees of freedom, which asks whether b1 differs from zero (section 9.2.5). When there is only one predictor, these two tests and the significance test of the Pearson correlation are one test in three disguises: F = t², and the p value is identical in all three. So the p in the calculator's table is at the same time the significance of the correlation, of the slope and of the whole model.

Assumptions, outliers and influential observations

The assumptions – in order of importance

Both variables are quantitative (scale or ordinal); a categorical variable (e.g. region or religion) is not suitable for a scatter plot – there, a box plot or analysis of variance is suitable. Beyond that, Field (2024, section 9.4.1) orders the assumptions of the linear model by importance, following Field & Wilcox (2017) and Gelman, Hill & Vehtari (2020, section 11.1). With the latter, the list opens with two assumptions that are not statistical at all, and they are the most important of all: validity – that the data answer the research question: the outcome variable truly measures the phenomenon (test scores are not "intelligence"), the model includes the relevant predictors, and it generalizes to the cases one wants to talk about; and representativeness – that the sample represents the distribution of Y given X. The practical distinction that follows from this is worth its weight in gold: selection of the sample by X (e.g. an excess of women or of tall people in a sample on height and income) does not harm the regression; selection by Y (an excess of rich people) does (pp. 153-154). Only after them come the four statistical assumptions, in this order:

1. Linearity

The relationship between X and Y is approximately a straight line. This is the assumption the scatter plot itself checks: if the cloud curves (e.g. in a U shape), the straight line is simply not the right model – and no number will fix that.

2. Independence

The residuals of different observations are not related to each other: each row is a different participant. Repeated measurements of the same person, or students from the same class, violate the assumption – and then the standard errors, the confidence intervals and the significance tests are not valid.

3. Equal residual variance

(homoscedasticity) The spread of the points around the line is similar along the whole range of X. A cloud that widens like a funnel – narrow on one side and wide on the other – indicates a violation; it harms the confidence intervals and the tests, not the estimates of the line itself.

4. Normal residuals

The deviations from the line are approximately normally distributed around zero. This assumption concerns the residuals, not the variables: X and Y themselves do not have to be normally distributed – a common confusion. In large samples it hardly matters (the central limit theorem); in small samples it affects the significance and the confidence intervals.

The important point behind this order: violating the assumptions mainly harms generalization – the significance tests and the confidence intervals – and not the estimates of the line. The slope and intercept the calculator shows are correct for the data in front of you even when the assumptions are not met; what becomes questionable is the inference from the sample to the population (Field, 2024, Section 9.4). More precisely (Field & Wilcox, 2017, Section Critical assumptions): when the residual variance is not equal or the observations are dependent on each other, the estimates of a and b remain unbiased – but the formula for their standard error assumes constant variance, so the standard errors are biased, and with them the p values and the confidence intervals. The line is right; the extent to which it can be trusted – is not. Likewise Cohen (1988, p. 75): as a descriptive measure of linear relationship, r requires no assumption at all – neither about the distribution of the variables nor about equality of variance; the assumptions come in only with the significance test, and even then a moderate violation of them, especially in a large sample, does not seriously harm the validity of the test. Two more practical requirements: the variables must have variance – a variable whose values are all identical cannot predict anything (the calculator shows an error message in such a case); and the outcome variable should be continuous and not "bounded" – a 1-5 scale in which all answers are concentrated at 4 and 5 limits what can be discovered.

And how to check. Linearity is checked in the scatter plot itself – that is the whole purpose of this page. The two assumptions about the residuals are checked in a residual plot, which is obtained from the regression procedure and not from the scatter plot: on the X axis the predicted values, on the Y axis the residuals, and you want to see an even band along the whole range – without a funnel (a violation of equal variance) and without an arc (a remnant of a nonlinear relationship). In SPSS: in the regression window, the Plots button, *ZPRED to X and *ZRESID to Y. And the normality of the residuals is better checked by eye – in a histogram or, better, in a Q-Q plot (there, under Normal probability plot): the closer the points are to the diagonal, the closer the distribution is to normal. The formal normality tests (Kolmogorov-Smirnov, Shapiro-Wilk) depend on the sample size more than on the shape of the distribution: in a small sample they are weak, and in a large sample they come out significant almost always, even for a tiny deviation – Pallant (2020, pp. 138-139) notes that this is common in large samples and refers, following Tabachnick & Fidell, to the histogram and the Q-Q plot instead. And Gelman, Hill & Vehtari (2020, p. 155) go a step further: for estimating the line – as opposed to predicting a single observation – the normality of the residuals is "barely important at all", so they do not recommend checking it at all; there is no harm in a Q-Q plot, but attention is better directed to validity, representativeness and linearity.

The residual plot itself is an idea of Anscombe (1973, p. 18), and it explains why the scatter plot is not enough: seemingly the residual plot cannot show anything that is not in the original graph, but once the line has been removed, the Y axis is stretched and what remains is clearly visible. Four things to look for in it: a few residuals much larger than all the others (outliers); residuals that line up in a curve (a nonlinear relationship); spread that gradually increases with the predicted values (unequal variance); and a skewed distribution of the residuals. The last three, with luck, disappear together with a transformation of Y – for example a logarithm – and the "curve" can also be resolved with a transformation of X or by adding a squared term. And each of them can, of course, be checked with a formal test, but the plot "shows a variety of features quickly and vividly, and formal tests often seem superfluous" (ibid.).

And what not to plot. After such a list of diagnostics, it is worth remembering the "quick tip" of Gelman & Hill (2007, p. 548): "Do you really want to make all those Q-Q plots, influence plots and all the other things that a statistical package spits out? What are you going to do with all of it?" – and the rule they propose instead: every graph you show – be prepared to explain. The scatter plot with the regression line and the residual plot are the two that almost always pass this test; add the rest when they have something to say.

An outlier and an influential observation – not the same thing

The calculator on the page flags in the chart and collects in the "Observations to check" table the points that exceed the thresholds of the three measures explained here – standardized residual, leverage and Cook's distance – with the standing caveat: exceeding a threshold is a reason to check, not to delete.

The second thing the scatter plot reveals, after the form of the relationship, is points that sit on their own – far from the cloud, at the end of one of the axes or both. Such a point may be a truly exceptional participant, but often it is just a digit that was entered incorrectly, so the first step is always to go back to the file and check the value. If it is real, Anscombe (1973, pp. 17-18) recommends setting the observation aside for separate study and fitting the line to the rest of the data – and adds that this study "may prove very rewarding". Why this matters precisely here: the Pearson correlation is very sensitive to a single point. Gravetter & Wallnau (2017, p. 499) demonstrate this with five points whose correlation is almost zero (r = −.08); adding one extreme point makes it jump to r = .85 – a "strong relationship" that rests entirely on one participant. Anyone who reads only the number will never know this. Field (2024, section 9.3) adds a distinction worth internalizing: an outlier is an observation the model predicts badly – its residual is large; an influential observation is an observation without which the line would look different. These are two different things, and an observation can be one without the other.

The example of Field (2024, Jane Superbrain 9.1) illustrates this nicely: in eight London boroughs the number of pubs and the number of deaths were measured. In seven of them the relationship is perfectly linear; the eighth – the City of London, one square mile with few residents and lots of pubs for commuters – sits far from all of them. And yet its residual is almost the smallest, because it "pulls" the line toward it until the line passes close to it. By the residual it is not an outlier; by the influence measures it changes the line completely. The conclusion: in a scatter plot, a single point far out at the end of the X axis is more dangerous than a point that is far from the line in the middle of the range.

Six configurations worth knowing. The book from which most modern influence measures came opens, of all things, with a scatter plot: Belsley, Kuh & Welsch (1980, pp. 8-9) present six stylized configurations of an "odd point", and they are a good map of what may be hiding in the cloud. In the figure below, the solid line is the regression line on all points, and the dashed line – the line that would be obtained without the marked points:

Six panels of stylized scatter plots: even spread; an outlier in the middle of the X range; a distant point consistent with the line; a distant point that determines the slope; two points that pull the line; two adjacent points that mask each other
Six configurations of an outlying observation in a scatter plot (after Belsley, Kuh & Welsch, 1980, Exhibit 2.1). Solid line – the regression on all points; dashed line – without the marked points

(a) Even spread – the desired situation; if the spread of X is small, the slope will not be precise, but its standard error already says so. (b) An outlier in the middle of the X range – a point far from the line, but near the mean of X: the slope hardly moves, only the intercept; this is the relatively "innocent" outlier, whose sign is a large residual. (c) A gap, but consistent – a distant point that sits exactly on the continuation of the line: not harmful, and even helpful – it reduces the variance of the slope estimate. This is the reminder that an extreme point is not necessarily a bad point. (d) The point that determines the slope – the most worrying configuration: without the distant point there is almost no relationship, and with it there is a clear relationship; in fact, as the authors put it, there are "effectively only two points" here. Its residual is small – the line passes through it – so residual measures will not catch it; leverage will. Cook & Weisberg (1982, pp. 102-103) open the discussion of influence with exactly such a graph, and stress that even someone who anticipates the change in the line will be surprised by what happens to the measures: with the distant point R² = .90; without it – less than .01. (e) Two that pull – two points with high leverage, each of which alone tilts the line; here, the authors write, action is required: omission, or – more gently – reducing their weight, or changing the model. (f) Mutual masking – two adjacent points: omitting one of them hardly changes the line, because the other keeps pulling, so measures that check observation by observation (such as Cook's distance) may miss both (ibid., pp. 9, 31). This is why there is no substitute for the eye: such a pair stands out in the scatter plot immediately.

For quantification: residuals in standard units (standardized residuals) – the residuals as z-scores: an absolute value above 3.29 is cause for concern; if more than 1% of the observations are above 2.58, or more than 5% above 1.96 – the model represents the data poorly; Cook's distance – the influence of the observation on the whole model: how much all the coefficients move together when it is omitted. The measure is, in the decomposition of Cook & Weisberg (1982, p. 117), a product of the two other factors in this list – the squared standardized residual times the "potential" of the leverage (h/(1 − h)) – so an observation can be influential for two different reasons: because it is far from the line, or because it is far out on the X axis; in the example they give (3.5.1) four observations get exactly the same D = 3, two for each reason. The accepted threshold, D > 1, means that omitting the observation moves the model estimates beyond a 50% confidence region – and Cook & Weisberg propose it as a "basis for comparison" only, and warn that the definition of "large" depends on the problem (p. 118); and the so-called leverage – how extreme the observation's X value is; check values above twice the mean, 2(k + 1)/n (Hoaglin & Welsch, 1978, section 2; Belsley, Kuh & Welsch, 1980, p. 17; with one predictor: 4/n). Leverage, h, is by definition the weight of the observation in its own predicted value – at h = 1 the model "devotes" a parameter to it and the regression line necessarily passes through it – and in simple regression it has a transparent formula: h = 1/n + (x − x̄)² / Σ(x − x̄)² – the observation's share of the total spread of X (Hoaglin & Welsch, 1978, Section 3). Two things worth remembering follow from this. In a scatter plot of two variables leverage is simply visible: an observation extreme on the X axis is an observation with high leverage, and no measure is needed; the measure becomes necessary only when there are several predictors, and then an observation can be remote in their combination without being extreme on any one of them, and no graph will reveal it (ibid., section 2). And second, the strategy Hoaglin & Welsch propose (section 5): check leverage to locate sensitive points on the X axis and the studentized residuals to locate outlying Y values – both, because an observation with high leverage may show a small residual precisely because it has already pulled the line toward it, and the residual measure alone will miss it. And a warning of theirs that balances all of the above: the extreme points on X are also those that carry most of the information about the slope, so omitting a leverage point may greatly reduce the precision with which it can be estimated – "such decisions cannot be made automatically". Belsley, Kuh & Welsch add two measures that also appear in the Save window of SPSS: Standardized DfBeta – by how many standard errors the slope moves when the observation is omitted, threshold 2/√n; and Standardized DfFit – how much its predicted value moves, threshold 2√(p/n), where p is the number of parameters including the intercept (1980, p. 28). Leverage measured the potential danger – how far the observation is on X; these two measure the actual damage. All of these are produced in SPSS from the regression procedure (the Save button), not from the scatter plot – see From the chart to regression.

A restricted range of values. A quiet trap that is not visible in the graph itself: when the sample covers only a narrow part of the possible range of values – for example measuring the relationship between IQ and achievement only among graduate students – the correlation obtained differs, and is usually lower, from the one that would be obtained from the full range. The wider the range of both variables in the sample, the more reliable the estimate of the relationship; and when an extreme group is studied deliberately (e.g. patients with a high level of anxiety), the correlation should not be generalized beyond the sampled range (Pallant, 2020, p. 136). In the scatter plot this looks like a cloud that covers only one corner of the axes. Cohen, Cohen, West & Aiken (2003, pp. 57-58) demonstrate this with numbers: when a sample of faculty members is restricted to those who completed their doctorate only 5-11 years earlier (instead of 3-18), the correlation between seniority and the number of publications drops from .657 to .388, and R² from .43 to .15 – whereas the regression slope hardly moves (1.98 versus 2.46). This is a general property: when the relationship is linear, b is stable under changes in the spread of X, and r is not. Hence two practical recommendations – always report the standard deviations of the variables, so that a reader can judge whether the range is restricted; and when comparing the relationship between samples whose standard deviations differ, compare the slopes and not the correlations.

What the graph cannot show: measurement reliability. Questionnaires measure with error, and measurement error attenuates every correlation: the correlation between two observed scores cannot exceed the square root of the product of their reliabilities, rXY ≤ √(rXX·rYY). Two scales with a reliability of .80 each cannot correlate beyond .80, and an observed correlation of .44 between them corresponds to a correlation of .55 between the "true" constructs – this is what is known as the correction for attenuation: divide r by that same square root (Cohen, Cohen, West & Aiken, 2003, pp. 55-57). Two things follow from this. First, unreliability is a sufficient explanation for a low correlation, but it cannot create a spuriously high correlation – a strong correlation between unreliable measures is an especially strong finding. Cohen (1988, p. 79) uses exactly this arithmetic to explain why r = .10 is not "too small" to look for: two theoretical constructs whose true correlation is .25, when each is measured with an instrument that correlates .63 with its construct, will correlate in measurement only .25 × .63 × .63 = .10 – "in psychology", in the quotation he brings from Thurstone, "we measure men by their shadows". Second, the corrected correlation is a hypothetical value and not a datum: report it only alongside the observed correlation, and with caution – when the reliabilities were estimated in another sample or were underestimated, the correction may give an inflated value, even greater than 1. And a subtle point about the regression line: the slope b is not affected by unreliability in Y (the noise there is absorbed in the residuals), but it is affected by unreliability in X. Reliability itself is computed on the Cronbach's alpha and scale score page.

An item against the scale it is part of. A related trap: a scatter plot of a single item against the scale score that includes it will always show a positive relationship – simply because the item is part of the sum. With k items that are not related to each other at all, each item correlates with the sum at 1/√k: with two items – .71, with four – .50, without any real relationship (Cohen, Cohen, West & Aiken, 2003, p. 59). That is why an item's correlation with the scale is always computed against the scale without it (corrected item-total correlation) – and this is exactly the column the reliability page produces. In the same spirit (ibid., p. 53): r = 1 is possible only when the two variables are distributed in the same shape, and the more the distributions differ – especially when they are skewed in opposite directions, or when both variables are dichotomous with very different proportions – the lower than 1 the ceiling of the correlation.

And the most important warning of all. The diagnostic measures are meant to see how well the model fits the data – not to justify deleting points in order to get a desired result, for example turning a nonsignificant slope into a significant one (Field, 2024, Section 9.3.3). Belsley, Kuh & Welsch (1980, pp. 3-4), who developed many of these measures, explicitly wrote them to prevent the common and equally unsuitable remedy – "throwing out the outliers", many of which, as they note, are not influential at all: an outlying observation is not necessarily a bad observation, and sometimes it carries the most interesting information in the sample; only after identifying it can its quality be judged and a decision made on what to do. An outlying observation that does not influence the line does not endanger the model, and in any case the interesting question is why it does not fit it. Two common methods for handling outliers are flawed for a fundamental reason (Field & Wilcox, 2017, Section Alternative estimators): trimming by standard deviations – for example omitting every observation further than 2.5 standard deviations from the mean, a common practice with reaction-time data – relies on the mean and standard deviation, which are themselves the measures most sensitive to outliers, so one large outlier "masks" others; and manual removal of outliers, after which the usual regression is run on what remains – ignores the fact that the data have already been "cleaned", so the standard errors obtained are wrong, however large the sample may be. The robust alternatives – 20% trimmed means, M-estimators that identify an outlier empirically and reduce its weight, and robust regression – are available mainly in R (ibid., pp. 17-18, 32-34); what is available in SPSS, and recommended in any case, is the bootstrap in the section From the chart to regression. And what is actually done when one observation contributed a lot to the line? Anscombe (1973, pp. 18-20) formulates the test and the solution. The test: we are more comfortable about a relationship that remains visible even after omitting a few observations – any of them – that is, a relationship that "pervades all the observations and does not derive mainly from one or two". And the solution, from an example of education expenditure in the fifty U.S. states in which Alaska, with predictor values far from all the others, contributed especially to the line: not to remove Alaska – because after it would come Hawaii, California, New York, "and where does one stop?" – but to report the regression on all the states, add that Alaska contributed a lot to it, and say what happens without it (there: the line hardly changed, the standard errors increased slightly and R² dropped). Both things – the relationship in all the data and the special contribution of the observation – are the finding. Cook & Weisberg (1982, p. 104) summarize the space of possibilities, after making clear that the measures they developed "are not intended to provide rules for rejecting data": an observation that originates in a measurement error, a typing error or unsuitable experimental conditions – correct or delete it; an observation that has no such explanation – a formal outlier test (with the caveat that it should not be expected to have much power), collecting more data, or – what is usually suitable – reporting both analyses, with the observation and without it. The final decision, they write, always depends on the context, so there is no blanket recommendation.

How many participants are needed?

The common rules of thumb – 10 or 15 participants per predictor – are simplistic to the point of uselessness (Field, 2024, Section 9.5): the required sample size depends on the strength of the relationship one expects to find and on the desired statistical power. With one predictor, and for a power of 0.8 as is customary (Cohen, 1988), Field computes: about 25 participants are enough to detect a strong relationship (R² ≈ .26), about 55 for a medium relationship (R² ≈ .13), but for a weak relationship (R² ≈ .02) hundreds are needed. And a small sample also misleads in the opposite direction: the R expected from completely random data is k/(N − 1) – with 21 participants and one predictor, even pure noise will give an R of 0.05, and it is easy to be impressed by a "relationship" that does not exist.

Field's numbers rest on Cohen's tables, and they are worth knowing in the original: in Table 3.4.1 (1988, p. 102), for a two-tailed test at the .05 level and power .80, 28 pairs are needed to detect r = .50, 85 for r = .30, and 783 for r = .10 (and for power .90: 37, 113 and 1,047). The small differences from Field's numbers stem from his defining the effect in terms of an R² of .02 / .13 / .26. The table can also be read in reverse: with n = 50, for example, the chance of detecting a medium relationship is only .57 (ibid., Example 3.4) – and that is a sample many consider perfectly reasonable. And a remark of Cohen's worth remembering: the tables are not valid when the range of values in the sample is restricted (p. 100) – see A restricted range of values above.

Where these numbers come from. Gelman & Hill (2007, p. 441) explain the logic behind every power table in one line: for there to be an 80% chance of getting a significant result, the true effect must be 2.8 standard errors from zero – 1.96 so that the 95% confidence interval does not include zero, plus 0.84 to reach the 80th percentile of the normal distribution. With the standard error of a correlation coefficient (in Fisher's z transformation, 1/√(n − 3)) this rule reproduces the numbers above: for r = .30 it comes to 85 participants, for r = .10 close to 780. Two practical conclusions follow from this. One: standard errors decrease like 1/√n, so to halve a standard error four times as many participants are needed – at r = .10 this is the difference between 783 and about 3,100 (ibid., p. 446). The second, more important: every power calculation assumes the true effect size, "an assumption that by its nature cannot be checked from the available data" – a previous sample that gave r = .30 is also consistent with a much weaker relationship – and therefore "significance should not necessarily be expected from a proposed study, even if the sample size was computed correctly" (ibid., p. 447). The power table is a planning tool, not a promise.

And how do you do it in SPSS?

The calculator on this page parallels the Simple Scatter procedure in the Graphs menu in SPSS. For the detailed guide see Field (2024, section 5.8) and Pallant (2020, pp. 153-157). SPSS has two routes to a scatter plot: the older dialog boxes (Legacy Dialogs), which we will go through here step by step, and the newer Chart Builder, which is shown at the end of the section. Both produce the same graph.

A note on versions. The screenshots in this section were produced in SPSS version 21. The procedures themselves are stable across versions, but the location of menu items, the names of tabs and the number of options in the gallery may change slightly – and if your screen looks a little different, that is probably the reason. Field (2024), on which this section relies, was also written for version 29. Field himself is reassuring on this – new versions come out between editions, and the procedures the book describes are hardly affected by them.

In the menu, select Graphs › Legacy Dialogs › Scatter/Dot…:

SPSS menu: Graphs › Legacy Dialogs › Scatter/Dot, on the data file of the five resilience variables
Step 1 – The menu: Graphs › Legacy Dialogs › Scatter/Dot…

In the Scatter/Dot dialog box that opens, select the type of graph from five options, and then click Define:

The Scatter/Dot dialog box in SPSS – five graph types, with Simple Scatter selected by default
Step 2 – Choosing the graph type in the Scatter/Dot box: Simple Scatter is selected by default

Simple Scatter – a scatter plot of one dependent variable and one independent variable; this is the main type, what this page computes, and it is also the one selected by default when the box opens. Overlay Scatter – several pairs of variables on the same graph. Matrix Scatter – a matrix that shows at once all possible pairs from a list of variables (these two are expanded on below, in the section Extensions). 3-D Scatter – a scatter plot of three variables at once. And Simple Dot, the only option here that is not a scatter plot – a dot plot that describes the distribution of one variable, similar to a histogram in which each observation is a dot.

Selecting Simple Scatter opens the Simple Scatterplot definition window: move the dependent variable to the Y Axis box and the independent variable to the X Axis box – in the example before us, trust (trust) on the Y axis and self-efficacy (efficacy) on the X axis:

The Simple Scatterplot window in SPSS: trust on the Y axis and efficacy on the X axis
Step 3 – The Simple Scatterplot window: the dependent variable in Y Axis, the independent in X Axis

Three more boxes in the window are useful, but not mandatory: Set Markers by colors the points by the categories of a third variable (the idea is old: Anscombe, 1973, p. 20, called it a triple scatterplot – a graph of two variables in which the point's symbol encodes a third variable, and for him it was a poor-but-sufficient substitute for a three-dimensional graph); Label Cases by adds a label to each point, useful for locating a particular outlying observation; and Panel by Rows/Columns splits the graph into separate subgraphs by groups (see Overlay Scatter in the next section). Clicking OK produces the graph:

SPSS output: the scatter plot of efficacy against trust, before adding a regression line
Step 4 – The output: the scatter plot of self-efficacy and trust, still without a regression line

Three things in this graph deserve attention before continuing. First, the points are arranged in a grid. Both variables are means of scale items, so they take values only in steps of half a point. This is perfectly fine, and does not indicate a problem in the data.

Second, and more important – far fewer points than 479 are seen on the screen. Participants whose values are identical on both variables are drawn on top of each other (overplotting), and a single point on the screen may represent dozens of observations. The practical meaning: in such a graph the strength of the relationship cannot be estimated by eye, because the density – the important information – is simply not visible; so it is measured with a number (r or R²) and not by impression. What is clearly visible is the shape of the cloud: the lower right corner – high self-efficacy together with low trust – is almost completely empty, and this is exactly the sign of a positive relationship. (In the chart on this page the points are drawn with partial transparency, so an accumulation of observations at the same place appears as a darker blot – a visual hint of density that the regular SPSS output does not have.) Another remedy for overplotting is adding jitter (jittering): add to each participant's value, on one axis or both, a tiny random "noise", so that points that sat on top of each other spread out a little and a sense of density is created. The values themselves do not change – only the drawing – and the computation is of course done on the original data (Cohen, Cohen, West & Aiken, 2003, p. 111). The case in which this technique is truly necessary is a scatter plot one of whose variables is categorical, for example gender coded 0/1: without jitter each group is a single vertical column, in which one participant cannot be distinguished from a hundred.

How much noise to add? Gelman & Hill (2007, p. 554) give a rule: for integer-valued data – a uniform random number between −0.3 and +0.3 for each value of X and of Y; and in general, "just enough so that the discrete nature of the data is still clear". For Likert data in steps of half a point, as in the example, the corresponding range is about ±0.15. They also reject the alternative of marking an overlapping point with a digit (2, 3…) or a special symbol: this is visually misleading, and in principle insufficient, because then the display of each participant depends too much on the other participants. In R this is geom_jitter(width = 0.15, height = 0.15) instead of geom_point in the script in the R section.

And third, there is an outlying observation here. In the upper left corner sits a lone point – self-efficacy 1.00 with trust 5.00 – far from the pattern of the other observations. This is exactly the observation that the assumptions section above recommends stopping to check: if it is a typing error, it has no place in the analysis; and if it is a real datum, it stays – but it is worth knowing it is there, and checking how much it pulls the regression line toward it. And finally, a small illustration of everything said in the previous paragraph: in the data file itself there is not one observation there but two – two participants with exactly the same values, drawn on top of each other and looking like a single point.

The editing stage: the Chart Editor window. Unlike the calculator on this page, in SPSS the regression line does not appear automatically with the graph – it is added in editing. Double-clicking (double-click) the graph in the output window opens it in a separate window, the Chart Editor, and next to it the Properties window opens – the editing center of the graph:

The SPSS Chart Editor window with the scatter plot and the Properties window next to it
Step 5 – Chart Editor: the graph opens for editing, with the Properties window next to it

One important rule in the Properties window: its tabs change according to what is selected in the graph. In the screenshot above nothing was selected, so only two tabs appear – Chart Size, in which the height and width of the graph are set in points (here 375 by 468.75, keeping the aspect ratio), and Variables. Clicking one of the scatter points selects the whole series of points, and adds two more tabs to the window:

The Marker tab in the Properties window: marker type, size and color
The Marker tab – the shape of the point, its size, the border width and the fill and border colors

In Marker the appearance of the points is set: Type – the shape of the marker (circle, square, triangle); Size – its size; and Fill and Border – the fill color and the border color. By default the fill is empty (Transparent) and the border black, hence the hollow circles in the output. This tab is more useful than it seems: shrinking the marker, or filling it with a light, transparent color, helps precisely in a dense graph like ours, in which many points sit on top of each other.

The Spikes tab in the Properties window: None, Floor, Origin, Centroid
The Spikes tab – connecting lines from each point to the floor, to the origin or to the center of the cloud

The Spikes tab adds from each point a thin line to a fixed anchor: Floor – to the X axis, Origin – to the origin of the axes, and Centroid – to the center of gravity of the cloud. The default, None, is also the recommended one for an ordinary scatter plot; Centroid can illustrate a lesson on spread around the center, but in a graph with hundreds of observations it creates a tangle of lines.

The Variables tab in the Properties window, with the Element Type list open showing Fit Line
The Variables tab – the type of element drawn in the graph; Fit Line is one of them

The Variables tab is the deepest of all: it shows the elements the graph is built from and the variables that feed them. The Element Type drop-down list reveals what else can be drawn on the same data – Marker (the points, and this is the existing element), Fit Line (a fit line), Interpolation Line, Distribution Line, Path and more. Here a new element can also be added to the graph with the New button. However, this route is usually unnecessary: the regression line is added with a single dedicated command, and that is the next step.

And adding the regression line itself. In the Chart Editor menu, select Elements › Fit Line at Total…. The command adds a new tab to the Properties window, Fit Line, in which the fit method is chosen (Fit Method): the default Linear is simple linear regression – exactly the one this page computes – and alongside it Quadratic, Cubic, Loess and Mean of Y. Clicking Apply and then Close adds the line to the graph, and shows the R Sq Linear value on it (in older versions of SPSS the label appears without the square sign, as the text "RSq Linear"). Closing the Chart Editor window returns the updated graph to the output window.

And what does Loess do? This is the interesting option among the alternatives to the straight line: a smoothed line that assumes nothing about the form of the relationship, but simply follows the trend in the data, segment by segment (locally weighted scatterplot smoother). Its proper use is as a check: if the relationship in the population is linear, the Loess line should look like a rough approximation of a straight line – in the metaphor of Cohen, Cohen, West & Aiken (2003, p. 112), like "a small child's freehand drawing of a straight line". If it clearly curves, a straight line is not the right model. Two things worth knowing: the window width (in SPSS: % of points to fit) determines the degree of smoothing – a value that is too small draws every zigzag in the noise, a value that is too large straightens even a real curve, so it is worth trying two or three values; and at the ends of the X range, where the data are sparse, the line is much less reliable than in the center (ibid., pp. 113-114).

And the confidence bands around the line. In the same Fit Line tab, below Fit Method, sits the Confidence Intervals group of options. The default is None – a bare line, without a band – and alongside it two options that look similar and are not similar at all: Mean and Individual (with the confidence level field, 95 by default). Mean draws the uncertainty in the line itself – where, in the population, the mean of Y passes at each value of X. Individual answers a completely different question – where a new individual participant is expected to fall – and its band is much wider, because it carries two sources of uncertainty instead of one: both the uncertainty in the line, and the spread of participants around it. Gelman & Hill (2007, pp. 47-48) put it this way: the standard error of a prediction for a new observation is somewhat larger than σ – the standard deviation of the residuals, which is the Std. Error of the Estimate in the Model Summary table – because of the uncertainty in estimating the regression coefficients; and in a normal approximation, about 50% of the actual values fall within ±0.67σ of the prediction, about 68% within ±σ and about 95% within ±2σ.

And why both bands are narrow in the middle and widen at the ends. This is not an SPSS phenomenon but a property of prediction itself: the uncertainty grows the further one moves from the mean of the predictor (Gelman & Hill, 2007, p. 44). In the formula for the standard error of prediction (ibid., p. 47, footnote 3) this can be seen directly – σforecast = σ √(1 + 1/n + (x − x̄)² / Σ(xi − x̄)²): the middle term shrinks as the sample grows; the third term grows the further the X value being predicted for is from the sample mean of X – hence the hourglass shape of the band; and the 1 at the start is exactly the difference between Individual and Mean: the spread of the individual participant around the line, which does not disappear even when the sample grows without limit. This is the same caveat stated here about the ends of the Loess line, and in the linear version it gets a graphic expression – the band itself announces where the line knows less.

And what to report. The two bands answer two different questions, so the choice between them is not a matter of taste: Mean says how well we know where the line passes, and Individual says how well one person can be predicted. The common mistake is to read the narrow band as if it says where the participants fall, whereas it says only where their mean passes – and in a large sample it is very narrow even when the spread around the line is enormous. In a results chapter, when the scatter plot is meant to describe a relationship and not to be used for prediction, the customary choice is Mean; and the figure note should state which band is shown and at what confidence level. This is not needless strictness but an explicit requirement: APA (2020, section 7.28) requires explaining in the note any shading or other design element that carries meaning, and says explicitly that when a graph includes error bars it must be stated whether they represent standard deviations, standard errors, confidence limits or ranges – and adds that it is worth stating the sample size alongside them. The calculator on this page draws the line without a band, so this is an addition that comes from SPSS only.

The Chart Editor window with the Elements menu open and the Fit Line at Total item; on the graph the regression line, its equation and the label R² Linear = 0.545
Step 6 – Elements › Fit Line at Total: the regression line on the scatter plot, and next to it the equation of the line (y = 1.16 + 0.69·x) and the label R² Linear = 0.545

Clicking Paste in any of the dialog boxes saves the action as syntax:

GRAPH
  /SCATTERPLOT(BIVAR)=efficacy WITH trust
  /MISSING=LISTWISE.

Note: the GRAPH command uses listwise deletion by default (/MISSING=LISTWISE), and not the pairwise deletion used by the correlations procedure and by this page's calculator. In a single scatter plot, of only one pair of variables, this has no practical meaning: both methods lead to exactly the same set of observations, because there are no additional variables here "because of which" additional observations are dropped.

The second route: Chart Builder

The route described so far is that of the older dialog boxes. In the newer versions of SPSS the main tool for building graphs is the Chart Builder, reached from Graphs › Chart Builder… (Field, 2024, Sections 5.3 and 5.8). The result is identical – the difference is in the way of building.

A message that appears at opening, and is worth understanding. When the Chart Builder opens, a box pops up reminding you that the measurement level of every variable must be defined correctly – Scale, Ordinal or Nominal – because the tool relies on it to know which variables are continuous and which are categorical (Field, 2024, SPSS Tip 5.1). This is not an error but a reminder: anyone who defined the variables properly in the Measure column in Variable View simply confirms and continues. In the first screenshot in this section exactly this can be seen – the five resilience variables are defined as Scale, and the demographic variables as Ordinal or Nominal.

The Chart Builder opening box: a reminder to define the measurement level and value labels
The Chart Builder route, step A – the opening box: a reminder, not an error

The box also reminds you of a second thing: if the graph includes a categorical variable, it is worth defining labels for its values (value labels) – so that the graph shows "Secular" and not "1". The Define Variable Properties button leads directly to the place where both things are fixed, and OK continues to the window itself.

The structure of the window. Four areas: Gallery – the gallery of graph types; the variable list; the canvas, in which a preview of the graph is built as you work; and on the right the Element Properties and Options buttons, which determine what exactly the graph shows and how it handles missing values. Inside the canvas, areas for dropping variables (drop zones) are marked with blue dashed lines, and the variables are dragged into them – instead of moving them with arrows as in the older boxes.

The Chart Builder window before choosing a graph, with the Scatter/Dot gallery
Step B – The window when it opens: the variable list, the empty canvas and the Scatter/Dot gallery

Two details in the screenshot deserve a look. First, next to each variable in the list appears the symbol of its measurement level – a ruler for Scale, bars for Ordinal and colored circles for Nominal; this is the same definition the previous box reminded you of, and here it is visible. And second, below the list appears the message "No categories (scale variable)" – it refers to the variable selected in the list and reports that it is continuous and therefore has no categories. At the bottom of the window there are four tabs: Gallery – the usual way, choosing from a ready-made gallery; Basic Elements – building from scratch, element by element; and next to them Groups/Point ID and Titles/Footnotes.

And building the scatter plot. In the Choose from list, select Scatter/Dot, and the gallery of scatter charts opens: Simple scatter, Grouped scatter, Scatterplot matrix, Simple dot plot, Summary point plot, Drop-line and the three-dimensional versions. Double-clicking Simple scatter (or dragging it to the canvas) places a graph with two drop zones – one for the Y axis and one for the X axis. Drag the variables into them and click OK:

The Chart Builder window after dragging trust to the Y axis and efficacy to the X axis
Step C – The ready window: trust in the drop zone of the Y axis, and efficacy in that of the X axis

And a small warning that saves confusion: above the preview it says "Chart preview uses example data" – the points you see in the window are not your data but demonstration data. The preview illustrates the structure of the graph, not its result, and the real graph is obtained only after OK – and when it is obtained, it is completely identical to the graph in step 4 above, the one produced by the older route. Two routes, exactly the same graph.

The rule of thumb for placement is the one we have already used: the outcome variable on the Y axis, the predictor on the X axis. Field adds a caveat worth remembering – in correlational research, in which both variables are measured at the same time, the words "predictor" and "outcome" describe only their position in the graph and do not indicate causality (2024, section 5.8.1).

The two extensions in the previous section also exist here, under other names: Grouped scatter adds a third drop zone, into which a categorical variable is dragged and the points are colored by it – the equivalent of Set Markers by (section 5.8.2); and Scatterplot matrix shows only one drop zone, into which all the desired variables are dragged at once – select them in the list with Ctrl (or Cmd on a Mac) and drag them together (section 5.8.4).

And who is the outlying point? A tip from Pallant (2020, pp. 76, 157) that saves searching through the file: in the Groups/Point ID tab of the Chart Builder, check Point ID label and drag the ID variable to the Point ID drop zone. In the resulting graph, open the Chart Editor, select Elements › Data Label Mode (the first item in the menu, in the screenshot of step 6 above) and click a point – and its ID number appears next to it. Without an ID variable, the row number assigned by SPSS is shown. This way you can go back to that participant's questionnaire and check whether it is a typing error. (In the calculator on this page, hovering over a point shows its values, but not the ID – the ID column is neutralized from the analysis.)

And the syntax here looks completely different. The Chart Builder also has a Paste button, but it does not produce the short GRAPH command we saw above but a GGRAPH command, and inside it a block in a dedicated language for describing graphs – GPL (Graphics Production Language), enclosed between BEGIN GPL and END GPL:

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=efficacy trust MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: efficacy=col(source(s), name("efficacy"))
  DATA: trust=col(source(s), name("trust"))
  GUIDE: axis(dim(1), label("efficacy"))
  GUIDE: axis(dim(2), label("trust"))
  ELEMENT: point(position(efficacy*trust))
END GPL.

Longer – but more explicit, and so worth learning to read. Each line answers a different question: DATA – which variables enter the graph; GUIDE: axis – what is written on each axis; SCALE – what kind of scale each axis uses; and ELEMENT – what is actually drawn (point, that is, points). The first line, * Chart Builder., is only a comment – SPSS adds it to document which window the command came from, and the period at its end is what terminates it. The details vary slightly according to the options chosen in the window, so the syntax you get may look slightly different.

And a bonus: the syntax reveals how SPSS understood each variable. Suppose that instead of self-efficacy we drag the religion variable to the X axis – a categorical variable with three categories. SPSS will not prevent this, will produce a graph, and this is what will appear in Paste:

DATA: dat=col(source(s), name("dat"), unit.category())
GUIDE: axis(dim(1), label("dat"))
SCALE: cat(dim(1), include("1", "2", "3"))
SCALE: linear(dim(2), include(0))
ELEMENT: point(position(dat*trust))

The two telltale words are unit.category() in the DATA line and cat in the SCALE line of the X axis – as opposed to linear on the Y axis. That is, one axis is categorical and the other continuous, and the list include("1", "2", "3") explicitly enumerates the three categories. The resulting graph is not a cloud of points but three vertical columns, one for each group, and no trend can be read from it, nor can a meaningful regression line be fitted to it. This is exactly the case described in the assumptions section: when the explanatory variable is categorical, the question is not "is there a rising trend" but "do the means differ between the groups" – and for that question a box plot and a comparison of means are suitable, not a scatter plot. (The rule does not concern only a nominal variable: an ordinal variable with few values, as here, will also give columns and not a cloud.)

The regression line is added exactly as described above, in the same Chart Editor – the two routes meet there. One tip from Field is worth knowing in this context: SPSS attaches a label next to the line, and sometimes it lands on top of the points and hides data; in such a case, simply turn it off in the Properties window. And in a grouped graph, after adding the line, SPSS will draw a separate line for each group – and comparing their slopes is exactly the question of whether the relationship is stronger in one group than in another (section 5.8.2).

Reading the output

Unlike the Correlations table, which shows the correlation coefficient r itself, SPSS shows on the scatter plot – in its corner, next to the regression line – the coefficient of determination, as the label "R Sq Linear = …". For example, in the scatter plot we have just defined – self-efficacy (X) against trust (Y) in the data file on this page (the 512 respondents, after pairwise deletion of missing values): R Sq Linear = .55, and N = 479.

To get back from R² to the Pearson coefficient r, take the square root and add the sign according to the direction of the regression line: here √.55 ≈ .74, and since the line rises (positive slope) we get r = .74 – exactly the value that appears in the correlation cell between self-efficacy and trust in the correlations table (the correlations page, the table of correlations among the five resilience variables), and the strongest correlation among the ten pairs there. This is also a convenient way to check yourselves: if you computed a Pearson correlation earlier, its square should equal the R² Linear the graph shows.

Beyond the size of the relationship, comparing the slope of the line with its equation illustrates the numerical meaning: in this sample the equation of the line is Ý = 1.159 + 0.687X – that is, for each increase of one point in the level of self-efficacy, the expected level of trust rises by about 0.69 points on average. The intercept (1.159), the expected value when X = 0, usually has no substantive meaning when 0 lies outside the range of values actually observed on the measurement scale.

From the chart to regression: the same numbers in the Regression procedure

The scatter plot shows R² and the line, but not the parameters and their tests. The same numbers the calculator here shows in the table are obtained in SPSS from the regression procedure: Analyze › Regression › Linear…, the dependent variable to the Dependent box and the predictor to the Independent(s) box (Field, 2024, Section 9.7). The output comes in three tables (section 9.8), and it is worth knowing where each of our values sits – and Table 1 on the page now shows all of them (adjusted R², the standard error of the estimate, F, and b and a with standard errors, t and confidence intervals). For regression with several predictors – the linear regression page:

Model Summary

R – with one predictor this is exactly the Pearson correlation (in absolute value); R Square – the R² in our table and in the label on the graph; Adjusted R Square – a version that corrects for sample size, relevant mainly when there are several predictors; Std. Error of the Estimate – the standard deviation of the residuals, the spread of the points around the line in units of Y.

ANOVA

The sums of squares Regression (SSM), Residual (SSR) and Total (SST) described above, and the F test: does the model predict better than the mean. With one predictor, Sig. here equals the p in our table.

Coefficients

The B column: the (Constant) row is the intercept a, and the predictor row is the slope b – with the standard error, the t test and Sig. (again the same p). Beta – the standardized slope, which with one predictor equals r.

Field recommends checking Bootstrap… in the main window and requesting BCa confidence intervals for b: a confidence interval that "does not touch zero" is the most direct evidence of a relationship in the population, and the bootstrap does not rely on the assumptions of normality and equal variance (2024, section 9.8.2). The idea is simple (Field & Wilcox, 2017, Section Adjusting standard errors): instead of assuming how b would be distributed in repeated samples, this is simulated – a new sample of the original size is drawn from the data themselves, with replacement, b is computed on it, and this is repeated thousands of times (a common recommendation: 2,000). The values that bound the middle 95% of these thousands of b values are the confidence interval (percentile), and BCa is a version that also corrects for asymmetry. Because the method assumes nothing about the shape of the distribution, the standard errors and confidence intervals it gives should hold up even under violations of the assumptions described above. And finally, the statement of Field & Wilcox (ibid., Section Discussion and recommendations) worth remembering when facing anyone who says that "regression is a robust method": on the basis of hundreds of studies from the last fifty years, this statement is simply not true – and they propose banning it. The rest of the procedure – several predictors, the diagnostic measures, the assumptions in the output – is detailed on the site's linear regression page.

Extensions: comparing groups and all pairs at once

Comparing groups in the same graph – Overlay Scatter. To show several pairs of variables together, or to compare the same pair across subgroups – for example, whether the relationship between self-efficacy and trust is similar in strength in different religious groups – select Overlay Scatter in the Scatter/Dot box and click Define:

The Scatter/Dot box with Overlay Scatter selected
Step A – In the Scatter/Dot box, select Overlay Scatter – a scatter plot of several pairs of variables on the same axes

In the Overlay Scatterplot window, select two variables at once in the variable list and move them to the Y-X Pairs list; each row in it is a pair, and the variable selected first becomes the Y variable of the pair. The arrows button (Swap Pair) swaps the Y and X of the selected pair – note that in the example before us self-efficacy is the Y while trust and belonging are the X, the reverse of the page's main example. To split the graph into subgraphs by group, move a categorical variable to the Columns box (subgraphs side by side) or Rows (one below the other) in Panel by – here the religion variable (dat):

The Overlay Scatterplot window: two Y-X pairs – self-efficacy against trust and self-efficacy against belonging, and a split into columns by religion
Step B – The Overlay Scatterplot window: two pairs in the Y-X Pairs list (efficacy against trust, efficacy against belonging), and the religion variable in the Columns box of Panel by

The output is three subgraphs side by side – secular, traditional and religious-Haredi – and in each of them two series of points in different colors, according to the legend on the right: self-efficacy against trust and self-efficacy against belonging. The axes are shared by all the subgraphs, so they can be compared directly:

Overlay Scatter output: three subgraphs by religion, each with two series – self-efficacy against trust and self-efficacy against belonging
Step C – The output: a subgraph for each religious group, and in each the two series; the regression lines have not yet been added

Here too the regression lines do not appear by themselves: open the graph in the Chart Editor and select Elements › Fit Line at Subgroups – then a separate line is obtained for each series in each subgraph, and in the legend on the right the R² Linear of each line (Pallant, 2020, p. 305):

Chart Editor: the three subgraphs with a regression line for each series, and in the legend R² Linear for each line
Step D – After Elements › Fit Line at Subgroups: a line for each series in each subgraph, and the six R² Linear values in the legend

Two pieces of advice from Gelman & Hill (2007, p. 555) for such a graph. The first – on symbols: for two or three groups, choose symbols that are distinguishable by eye – an open circle against a filled circle, not the letters M and F – because a symbol is the way the graph says "each point is a participant from this group"; the size of the symbol, by contrast, hardly succeeds in representing a continuous variable. The second – a story from their own work: they drew a before-and-after graph with separate regression lines for treatment and control groups, and only after seeing the graph with parallel lines did they realize that nonparallel lines – that is, an interaction between the treatment and the "before" measurement – are the right model, and this turned out to be the central fact of the data. "The lines and points together show this much more clearly than any numerical summary" (ibid.). This is exactly what the Overlay chart with Fit Line at Subgroups makes it possible to check: whether the slopes are similar.

This way one graph can answer the two questions it was built for. Which of the two relationships is stronger? Among secular respondents self-efficacy is related to trust (R² = .554) more than to belonging (.460), and among religious-Haredi respondents the gap is similar (.506 versus .404) – whereas among traditional respondents the two are almost equal (.525 and .536). And is the relationship similar across the groups? The self-efficacy–trust relationship is fairly stable in all three (.51-.55), and the self-efficacy–belonging relationship varies more (.40-.54). Note that the numbers in the legend are R² and not r: a difference between .554 and .460 is a difference between r = .74 and r = .68. And a warning that follows directly from the assumptions section – the six configurations and leverage: when a group is small – like the religious-Haredi respondents in this sample, whose subgraph is clearly sparse – two or three points with high leverage are enough to tilt its line in any direction, so slopes are compared across groups only after checking how many participants there are in each, and if the difference matters – it is tested with a test and not by eye.

Clicking Paste in the Overlay Scatterplot window saves the definition as syntax – and it is shorter and more explicit than the window itself:

GRAPH
  /SCATTERPLOT(OVERLAY)=trust belonging WITH efficacy efficacy (PAIR)
  /PANEL COLVAR=dat COLOP=CROSS
  /MISSING=LISTWISE.

Read it like this: OVERLAY – several pairs on the same axes; before WITH the X variables and after it the Y variables, in order, and (PAIR) instructs pairing them one-to-one – the first with the first, the second with the second (and not each with each). Here: trust with efficacy and belonging with efficacy – again we see that self-efficacy is the Y. /PANEL COLVAR=dat is the split into columns by religion (ROWVAR would split into rows), and /MISSING=LISTWISE – as in the single graph – omits a participant who is missing a value on any of the variables in the command; in a graph of several pairs this already matters, because a participant missing only belonging will also disappear from the self-efficacy–trust pair. For pairwise deletion, change to /MISSING=VARIABLEWISE.

A look at all pairs at once – Matrix Scatter. To check all pairs of variables at once – for example among the five resilience variables – use Matrix Scatter: move all the variables to the Matrix Variables list and confirm. Each cell in the matrix is a scatter plot of one pair, so the whole matrix stands opposite the correlation matrix on the correlations page cell against number – and shows what the number cannot: whether one of the pairs is curved, and whether one of them has an observation pulling the line. So it is worth looking at it before computing the correlations and not after. And an advantage unique to it: a participant who stands out in one cell can be looked for in the other cells, to see whether they are outlying on all the variables or only in one pair – Cohen, Cohen, West & Aiken (2003, pp. 115-116) demonstrate this by highlighting the same participant in all the cells.

The Scatter/Dot box with Matrix Scatter selected
Step A – In the Scatter/Dot box, select Matrix Scatter

In the Scatterplot Matrix window, move to the Matrix Variables list all the variables you want to see – here the five resilience variables. The other boxes are familiar from the single graph: Set Markers by for coloring by group, Label Cases by for labels, and Panel by for splitting:

The Scatterplot Matrix window with the five resilience variables in the Matrix Variables list
Step B – The Scatterplot Matrix window: the five variables in the Matrix Variables list

The output is a grid of 5×5 cells. The diagonal is empty – a variable against itself is not interesting – and every other cell is a scatter plot of a pair: the row variable on the Y axis, the column variable on the X axis. The two halves of the grid are mirror images – the "leadership against self-efficacy" cell above the diagonal is the same graph as "self-efficacy against leadership" below it, with the axes swapped – so it is enough to look at one half – until regression lines are added: in each cell the line is that of the row variable on the column variable, so the lines in the two twin cells are not mirror images but two different lines, Y on X and X on Y (see And what happens when the axes are swapped). According to Cohen, Cohen, West & Aiken (2003, p. 115) this is the main upgrade of the matrix over the correlation table: the table shows only the direction and strength of a linear relationship, whereas the matrix also reveals nonlinear relationships, which in the table simply appear as a low correlation. And again the familiar grid: all the variables are item means in steps of half a point, so the points are arranged in rows and columns, and one point represents many participants:

Matrix Scatter output: a 5×5 grid of scatter plots among the five resilience variables, the diagonal empty
Step C – The output: ten pairs (twice, on both sides of the empty diagonal) – each cell a scatter plot of the row variable against the column variable

And as in any scatter plot, the regression line is added in editing: Chart Editor and then Elements › Fit Line at Total – one action that adds a line to all the cells at once:

The same matrix with a regression line in each cell
Step D – After Fit Line at Total: a regression line in each of the twenty cells

What is seen here at a glance? All ten relationships are positive and clear – all the lines rise and no cloud curves – so Pearson is suitable for all of them; this is exactly the graphic counterpart of the correlation matrix on the correlations page (there: r between .62 and .74). What is hard to see in such a grid is differences in strength between the pairs: the density hides them, and the comparison is made with the numbers. On the other hand, the more important question – whether there is a pair that behaves differently from the others, in a curved form or with outlying points – the matrix answers better than any table. Here too Paste saves the syntax, and here too /MISSING=LISTWISE: a participant missing a value on one of the five variables disappears from all twenty cells, so the N in each cell is smaller than that of the single graph of the same pair:

GRAPH
  /SCATTERPLOT(MATRIX)=leadership efficacy readiness belonging trust
  /MISSING=LISTWISE.

Reporting the results

Reporting a scatter plot usually includes the graph itself (with the regression line), and alongside it – in the text – the direction and strength of the relationship, the coefficient of determination, and sometimes also the equation of the line. When the scatter plot accompanies a correlation computation, as here, it is customary to report both together: the graph as visual support, and the correlation as a numerical summary. The graph itself is formatted as a "figure" (Figure) according to APA rules: the figure number above, a descriptive title in italics, axes with the names of the variables, and below the figure a note explaining what each point represents and what the line is – exactly like the sample scatter plot in the manual, in which each point is a participant and the regression lines are explained in the note (American Psychological Association [APA], 2020, Sections 7.22-7.28; Section 7.36, Figure 7.15).

Sample report · English

To examine the relationship between self-efficacy and trust, a scatter plot was drawn, and a linear regression line was fitted alongside it. The graph revealed a strong positive relationship, without prominent outlying observations: the higher the level of self-efficacy, the higher the level of trust (r(477) = .74, 95% CI [.69, .78], p < .001). The coefficient of determination, R² = .55, indicates that about 55% of the variance in trust is explained by self-efficacy. The equation of the regression line: Trust′ = 1.16 + 0.69 × Self-efficacy (b = 0.69, SE = 0.03, 95% CI [0.63, 0.74]).

Sample write-up · English

A scatterplot with a fitted linear regression line was used to examine the relationship between efficacy and trust. The plot revealed a positive, strong relationship with no salient outliers: higher levels of efficacy were associated with higher levels of trust, r(477) = .74, 95% CI [.69, .78], p < .001. The coefficient of determination, R² = .55, indicated that efficacy accounted for approximately 55% of the variance in trust. The regression equation was: trust′ = 1.16 + 0.69 × efficacy (b = 0.69, SE = 0.03, 95% CI [0.63, 0.74]).

The graph, the table and the report sentences in this format – r and R² to two digits without a leading zero, b and a with a leading zero, the confidence intervals for r and for b (Field, 2024, Section 9.14) – are produced automatically from the data file by the calculator on this page, and can be downloaded as a Word file; the graph itself is copied from the screen, and the figure note – from the output table.

When the regression is the main thing. If the emphasis in the work is on the model and not on the correlation, Field (2024, section 9.14) defines a minimum for reporting: b with its standard error and confidence interval (preferably bootstrap), the exact p value, the standardized coefficient β, and R² – and preferably also the intercept, so that a reader can reconstruct the equation. According to APA rules (APA, 2020, Section 6.36), values that cannot exceed 1 – β, R² and p – are written without a zero before the decimal point (.55 and not 0.55); b and the intercept, which can, are written with the zero. The standard error and confidence interval of b are not in the table on this page – they are produced in the regression procedure (see From the chart to regression). And in a minimal formulation: the estimated effect (b), its standard error and the p value – and alongside them a sentence explaining what the coefficient says, so that every reader understands; and in the case of simple regression, the scatter plot with the line is the best way to present the result.

And how is it done in R?

Exactly the same graph – points, regression line, italic title and figure note – comes out in R in a single script, with the ggplot2 graphics package. The conventions are identical to the R section on the site's other pages: a UTF-8 file, every comment line starts with an English word, short English names for the formula (efficacy = self-efficacy, trust = trust), and a UTF-8 environment for Hebrew names (on Windows: Sys.setlocale("LC_ALL", "Hebrew") or R 4.2 and above). The script is built in four parts: the numbers, the graph, saving, and the confidence bands. It was run as is on the page's sample file (DATA_scatter_example_eng.xlsx, the sheet "data") in R 4.3.3, and the results – identical to Table 1 and to the report sentences – are recorded in the comments. Replace the path and the variable names with your own; in R the path is written with a regular slash (/).

# Scatter plot and regression line – Professor Stat. This file is saved in UTF-8; every comment line starts with an English word
# Once only, if the packages are not installed: install.packages(c("readxl", "ggplot2", "ragg"))
library(readxl)    # Reading Excel
library(ggplot2)   # Graphics

# Loading: the standard layout – row = participant, column = variable; the sheet "data"
d <- read_excel("C:/Rdata/DATA_scatter_example_eng.xlsx", sheet = "data")
d <- d[, c("efficacy", "trust")]
names(d) <- c("efficacy", "trust")          # Short English names for the formula

# --- 1. The numbers (identical to Table 1 on the page) ---
cor.test(d$efficacy, d$trust)               # r = .738, t(477) = 23.90, p < .001, confidence interval [.695, .776]
cor.test(d$efficacy, d$trust, method = "spearman", exact = FALSE)   # rho = .728
fit <- lm(trust ~ efficacy, data = d)       # Regression line: trust on efficacy (automatic pairwise deletion)
summary(fit)                                # a = 1.159 (SE .096), b = 0.687 (SE .029, t = 23.90), s = 0.715, R² = .545, adjusted .544, F(1, 477) = 571.4
confint(fit)                                # 95% confidence intervals: a [0.970, 1.349], b [0.631, 0.744]
nobs(fit)                                   # N = 479 – observations with a valid value on both variables

# --- 2. The graph ---
p <- ggplot(d, aes(x = efficacy, y = trust)) +
  geom_point(colour = "#5B63B0", alpha = 0.55, size = 2.2) +
  geom_smooth(method = "lm", se = FALSE, colour = "#37716D", linewidth = 0.9) +
  labs(x = "Self-efficacy", y = "Trust",
       title = "Figure 1",
       subtitle = "Trust as a function of self-efficacy",
       caption = paste0("Note. Each point represents one participant, by their values on self-efficacy (horizontal axis) and trust (vertical axis).\n",
                        "The line is the linear regression line of trust on self-efficacy. N = ", nobs(fit),
                        " observations with a valid value on both variables.")) +
  theme_minimal(base_size = 13) +
  theme(plot.title = element_text(face = "bold"),
        plot.subtitle = element_text(face = "italic"),
        plot.caption = element_text(hjust = 1, size = 10),
        panel.grid.minor = element_blank())
p

# --- 3. Saving for the paper: 300 dpi, AGG engine (correct Hebrew and punctuation) ---
ggsave("C:/Rdata/scatter_trust_efficacy.png", p, width = 7, height = 4.5, dpi = 300, device = ragg::agg_png)

# --- 4. The confidence bands: Mean versus Individual (as in the chart on the page when both bands are checked) ---
# Explanation: Mean – 95% confidence interval for the line itself: se = TRUE in geom_smooth (its default); Individual – 95% prediction interval for an individual participant: predict(interval = "prediction")
grid <- data.frame(efficacy = seq(min(d$efficacy, na.rm = TRUE), max(d$efficacy, na.rm = TRUE), length.out = 100))
pred <- cbind(grid, predict(fit, newdata = grid, interval = "prediction", level = 0.95))
pred[c(1, 50, 100), ]                        # For example x = 3: ŷ = 3.22, prediction interval [1.81, 4.62]; the band width increases slightly at the ends

p_ci <- ggplot(d, aes(x = efficacy, y = trust)) +
  geom_ribbon(data = pred, aes(x = efficacy, ymin = lwr, ymax = upr), inherit.aes = FALSE, fill = "#A7D6D5", alpha = 0.35) +   # Individual
  geom_point(colour = "#5B63B0", alpha = 0.55, size = 2.2) +
  geom_smooth(method = "lm", se = TRUE, level = 0.95, colour = "#37716D", fill = "#37716D", alpha = 0.35, linewidth = 0.9) +  # Mean
  labs(x = "Self-efficacy", y = "Trust",
       title = "Figure 2",
       subtitle = "Trust as a function of self-efficacy, with confidence bands",
       caption = paste0("Note. Each point represents one participant; N = ", nobs(fit), " observations with a valid value on both variables.\n",
                        "The line is the linear regression line of trust on self-efficacy.\n",
                        "The dark band – 95% confidence interval for the line (Mean); the light band – 95% prediction interval for an individual participant (Individual).")) +
  theme_minimal(base_size = 13) +
  theme(plot.title = element_text(face = "bold"),
        plot.subtitle = element_text(face = "italic"),
        plot.caption = element_text(hjust = 1, size = 10),
        panel.grid.minor = element_blank())
p_ci

ggsave("C:/Rdata/scatter_trust_efficacy_ci.png", p_ci, width = 7, height = 4.5, dpi = 300, device = ragg::agg_png)

What happens in each part. In part 1, cor.test gives r, the degrees of freedom, the p and the confidence interval (in Fisher's transformation – the same interval as in Table 1), and the same function with method = "spearman" gives rs; lm estimates the line, summary prints the intercept and slope with their standard errors, t and p, the standard error of the estimate (Residual standard error), R² and F – in the sample data 1.159 and 0.687, s = 0.715, R² = .545, exactly the rows of Table 1 produced by the calculator; confint gives the confidence intervals of the coefficients, and nobs returns N = 479. In part 2, geom_point draws the points (with transparency, because on a Likert scale many participants sit on exactly the same point, and this way you see where the cloud is dense), geom_smooth(method = "lm", se = FALSE) adds the regression line without a band, and labs gives the figure the APA components: a number, an italic title (subtitle with face = "italic"), the variable names on the axes, and the figure note in caption – what each point represents, what the line is and the sample size, right-aligned with hjust = 1. Part 3 saves a PNG file at 300 dpi at a fixed size, and this is the version that goes into the paper – not the export from the Plots pane, which is saved at screen resolution and at the size of the window.

The two "warnings" are not an error. After every run, Removed 33 rows containing missing values is printed: 512 participants in the file minus 479 with a valid value on both variables – R is simply reporting the pairwise deletion, the same method used by SPSS and by the calculator on the page. Nothing needs to be done. The missing values are removed automatically in all three steps – cor.test, lm and the graph – so the numbers are identical to those in the table: r(477) = .738, p < .001.

The Hebrew trap – and how to get around it. On the first run the Hebrew in the graph will probably look fine, but the punctuation in the figure note will get mixed up: the final period will jump to the left of the line, and N = 479 will wander to the wrong place in the sentence (this also happened in the page's test run, in a Linux environment without this engine). This is not a problem in the code but in the graphics engine with which RStudio draws by default: it arranges Hebrew letters from right to left, but assumes that the base direction of the line is left to right, so everything that is not a Hebrew letter – a period, parentheses, a Latin-script number – falls in the wrong place. Titles and axis labels of a word or two are not affected; a whole sentence with punctuation – is. The solution is a graphics engine that implements the Unicode bidirectional algorithm properly, AGG, which comes in the ragg package, in two places: in the file – this is the argument device = ragg::agg_png in the ggsave line in the script; and in the Plots pane – once, in the settings: Tools › Global Options › General › Graphics › Backend: AGG, and then Apply and OK:

The RStudio Global Options window: General, Graphics tab, the Backend field set to AGG
Tools › Global Options › General › Graphics – Backend: AGG. From that moment every graph on the screen is drawn with the right engine

And two more small rules for Hebrew in R: save the script file in UTF-8 encoding (in RStudio: File › Save with Encoding) – otherwise the Hebrew may turn into dots or squares; and when splitting a long Hebrew note into several lines with \n, start each line with a Hebrew word and not with a Latin letter or a number – a line that opens with N = 479 will be laid out as a left-to-right line, and its period will run away again.

The confidence bands – a live demonstration of Mean versus Individual

Part 4 of the script draws the two bands described in the section The Fit Line tab – and you can see with your own eyes why the distinction between them matters. The Mean band requires one word: se = TRUE in geom_smooth (in fact this is its default – deleting se = FALSE is enough), and this is a 95% confidence interval for the line itself. The Individual band is not built into ggplot2, so it is computed directly from the model: predict(fit, newdata, interval = "prediction") returns for each value of X the prediction and the limits of the prediction interval for an individual participant, and geom_ribbon draws them as a band. Both bands are drawn at the same confidence level, 95%, and yet:

Scatter plot of trust as a function of self-efficacy with a regression line, a narrow dark band around the line (confidence interval for the line) and a wide light band (prediction interval for an individual participant)
The output of part 4: the dark band around the line – Mean, a 95% confidence interval for the line; the light band – Individual, a 95% prediction interval for an individual participant. The same confidence level, a completely different width

The Mean band is almost swallowed by the line: with 479 participants we know well where the mean line passes, and in an even larger sample it would shrink to zero. The Individual band extends over two or three points on the scale – because it also includes the spread of participants around the line, the σ of that section, which does not disappear at any sample size. And both, if you look closely, are narrowest around the mean of X and widen slightly toward the ends – the hourglass shape. The figure note in the code states explicitly what each band represents and at what confidence level, as APA (2020, section 7.28) requires – and this is why in a results chapter usually only Mean is reported: the question there is "where does the relationship pass", not "where will a new participant fall".

References

American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000

Anscombe, F. J. (1973). Graphs in statistical analysis. The American Statistician, 27(1), 17-21.

Belsley, D. A., Kuh, E., & Welsch, R. E. (1980). Regression diagnostics: Identifying influential data and sources of collinearity. Wiley.

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.

Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Lawrence Erlbaum Associates.

Cook, R. D., & Weisberg, S. (1982). Residuals and influence in regression. Chapman & Hall.

Field, A. (2024). Discovering statistics using IBM SPSS statistics (6th ed.). SAGE.

Field, A. P., & Wilcox, R. R. (2017). Robust statistical methods: A primer for clinical psychology and experimental psychopathology researchers. Behaviour Research and Therapy, 98, 19-38. https://doi.org/10.1016/j.brat.2017.05.013

Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge University Press.

Gelman, A., Hill, J., & Vehtari, A. (2020). Regression and other stories. Cambridge University Press.

Gravetter, F. J., & Wallnau, L. B. (2017). Statistics for the behavioral sciences (10th ed.). Cengage Learning.

Hoaglin, D. C., & Welsch, R. E. (1978). The hat matrix in regression and ANOVA. The American Statistician, 32(1), 17-22. https://doi.org/10.1080/00031305.1978.10479237

Pallant, J. (2020). SPSS survival manual: A step by step guide to data analysis using IBM SPSS (7th ed.). Routledge.