Scatter Plot Maker
Paste pairs of values and get a scatter plot with the least-squares line of best fit, its equation, and the correlation coefficient r and r², each worked out step by step. Download the plot as a PDF, PNG or SVG, or share it with a link.
Data
Chart and downloads
The PDF has the chart and every step of the working on Letter paper. Print it at 100% or Actual size. Your data stay in this browser.
Titles and labels
Scatter plot settings
Working and PDF
Worked statistics
Sums of squares
n = 12 pairs. x: Hours studied. y: Test score.
Mean of x = 4.17 (rounded); mean of y = 73.67 (rounded)
Sxx = sum of (x − mean of x)² = 49.67 (rounded)
Syy = sum of (y − mean of y)² = 1076.67 (rounded)
Sxy = sum of (x − mean of x)(y − mean of y) = 220.67 (rounded)
Line of best fit (least squares)
Slope b = Sxy ÷ Sxx = 220.67 ÷ 49.67 = 4.44 (rounded)
Intercept a = mean of y − b × mean of x = 55.15 (rounded)
Least-squares line: y = 4.44x + 55.15
Slope: each increase of 1 in Hours studied goes with an increase of about 4.44 in Test score, on average.
The slope and intercept are worked out from the exact sums, so redoing them with the rounded values above can change the last digit.
Correlation
r = Sxy ÷ square root of (Sxx × Syy) = 0.954 (rounded)
r² = 0.911 (rounded): about 91% of the variation in Test score goes with the straight-line relationship with Hours studied.
r = 0.954 suggests a strong positive linear association. As a rough guide (cut-offs vary between textbooks), r of 0.8 or more either way is often called strong, 0.5 to 0.8 moderate and 0.3 to 0.5 weak. Correlation does not show that one causes the other.
What a scatter plot shows
A scatter plot shows two measurements taken from the same people or things, such as each student's hours of study and test score, as one point per pair. The pattern of the points shows whether and how the two are associated. Common Core 8.SP.A.1 asks students to describe "clustering, outliers, positive or negative association, linear association, and nonlinear association"; England's key stage 3 programme and GCSE Mathematics cover scatter graphs, correlation and lines of best fit.
Describing the association
- Direction: positive if y tends to rise as x rises, negative if it tends to fall.
- Form: linear if the points follow a straight line, curved (nonlinear) if they bend.
- Strength: strong if the points sit close to the line, weak if they are widely scattered around it.
- Unusual points: outliers far from the pattern, and clusters of points apart from the rest.
The least-squares line and r
The tool fits the line that makes the squared vertical distances from the points to the line as small as possible. With Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)² and Sxy = Σ(x − x̄)(y − ȳ), the slope is b = Sxy ÷ Sxx and the intercept a = ȳ − b x̄ (NIST/SEMATECH e-Handbook, section 4.4.3.1), and the correlation coefficient is r = Sxy ÷ √(Sxx × Syy). All three come from the same exact sums, so the equation and r always agree with each other.
Worked example
Twelve students recorded how many hours they studied for a test and their score: (1, 58), (2, 62), (2, 67), (3, 65), (3, 72), (4, 70), (4, 77), (5, 74), (5, 81), (6, 83), (7, 84), (8, 91). The tool's plot and working, from when this page was built:
Sums of squares
n = 12 pairs. x: Hours studied. y: Test score.
Mean of x = 4.17 (rounded); mean of y = 73.67 (rounded)
Sxx = sum of (x − mean of x)² = 49.67 (rounded)
Syy = sum of (y − mean of y)² = 1076.67 (rounded)
Sxy = sum of (x − mean of x)(y − mean of y) = 220.67 (rounded)
Line of best fit (least squares)
Slope b = Sxy ÷ Sxx = 220.67 ÷ 49.67 = 4.44 (rounded)
Intercept a = mean of y − b × mean of x = 55.15 (rounded)
Least-squares line: y = 4.44x + 55.15
Slope: each increase of 1 in Hours studied goes with an increase of about 4.44 in Test score, on average.
The slope and intercept are worked out from the exact sums, so redoing them with the rounded values above can change the last digit.
Correlation
r = Sxy ÷ square root of (Sxx × Syy) = 0.954 (rounded)
r² = 0.911 (rounded): about 91% of the variation in Test score goes with the straight-line relationship with Hours studied.
r = 0.954 suggests a strong positive linear association. As a rough guide (cut-offs vary between textbooks), r of 0.8 or more either way is often called strong, 0.5 to 0.8 moderate and 0.3 to 0.5 weak. Correlation does not show that one causes the other.
The points show a strong positive linear association. The slope says each extra hour of study goes with about 4.44 more points, on average, and the line predicts a score of about 81.8 for 6 hours. The intercept, 55.15, is the predicted score with no study at all (x = 0). Here x = 0 is just below the smallest number of hours in the data, so it is a fair estimate; an intercept far outside the data often means nothing.
Drawing a line of best fit by hand
- Plot the points with even scales on both axes, labelled with what was measured.
- Lay a ruler along the trend so that roughly as many points sit above it as below, along its whole length.
- Check the line goes through the mean point (x̄, ȳ), if you have worked it out: the least-squares line always does.
- Read predictions from the line inside the range of the data, not far beyond it.
Common mistakes
- Joining the dots instead of drawing one straight line through the trend.
- Forcing the line through the origin or through the first and last points.
- Swapping x and y. The variable you predict from goes on the x-axis.
- Calling a strong correlation proof of cause.
- Extrapolating far beyond the data, where the trend may not hold.
Frequently asked questions
What is a line of best fit?
A straight line through the middle of the points that sums up the trend. Drawn by eye, it should follow the direction of the points with about as many above it as below. The tool draws the least-squares line, the one that makes the sum of the squared vertical distances from the points to the line as small as possible; for the example it is y = 4.44x + 55.15.
What does the correlation coefficient r mean?
r measures how closely the points follow a straight line, from −1 (a perfect falling line) through 0 (no straight-line pattern) to 1 (a perfect rising line). The example's r of 0.954 is a strong positive correlation. r only measures straight-line association: points on a curve can have an r near 0 and still be closely related.
What is r²?
The square of r. It is the fraction of the variation in y that goes with the straight-line relationship with x: an r² of 0.911 means about 91% of the variation in test scores goes with the variation in hours studied, and the rest with everything else.
Does a strong correlation mean one thing causes the other?
No. Two variables can move together because both depend on a third (ice-cream sales and sunburn both rise in hot weather), or by chance in a small sample. Common Core (HSS-ID.C.9) and GCSE Mathematics both ask students to know that correlation does not show causation.
Can I use the line to predict values outside my data?
Carefully, if at all. Predicting inside the range of the data (interpolation) is usually reasonable. Predicting far outside it (extrapolation) assumes the straight-line trend carries on, which it often doesn't: the example's line predicts a score of 144 for 20 hours of study, which is impossible on a test out of 100.