How to use the scatter plot maker
- Type or paste your x values in the first box and the matching y values in the second. Both lists need the same number of values.
- Add a chart title and axis labels, including units, so the chart makes sense on its own.
- Leave Show trend line on to draw the least-squares line, or turn it off for a plain scatter plot.
- Click Make scatter plot. You'll get the chart, the correlation coefficient r, the equation of the line and the full working.
- Click Download PNG to save the chart for your report, homework or slides.
The formulas behind the trend line
The trend line is the least-squares regression line: the straight line that makes the squared vertical distances from the points to the line as small as possible. Its equation is
ŷ = a + bx
The slope, intercept and correlation coefficient are calculated as:
b = Σ(x − x)(y − y)Σ(x − x)2
a = y − bx
r = Σ(x − x)(y − y)Σ(x − x)2 · Σ(y − y)2
- x, y
- The paired values: one x and one y for each observation
- x, y
- The mean of the x values and the mean of the y values
- Σ
- "Add up", over every pair
- b
- The slope: the average change in y for each one-unit increase in x
- a
- The intercept: the predicted y when x is 0
- ŷ
- The predicted ("fitted") value of y on the line
- r
- Pearson's correlation coefficient, from −1 to 1
- r2
- The coefficient of determination: the share of the variation in y explained by the line
Worked example
A small shop tracks its weekly ad spend and sales, both in thousands of dollars, for five weeks. Does spending more on ads go with higher sales?
Ad spend x: 1, 2, 3, 4, 5 · Sales y: 2, 4, 5, 4, 5
-
Find the mean of each variable
x = 1 + 2 + 3 + 4 + 55 = 3 y = 2 + 4 + 5 + 4 + 55 = 4
-
Find each deviation from the mean, then the products and squares
x y x − x y − y (x − x)(y − y) (x − x)² (y − y)² 1 2 −2 −2 4 4 4 2 4 −1 0 0 1 0 3 5 0 1 0 0 1 4 4 1 0 0 1 0 5 5 2 1 2 4 1 Sum 0 0 6 10 6 -
Slope
b = 610 = 0.6
-
Intercept
a = 4 − 0.6 × 3 = 2.2
-
Correlation coefficient
r = 610 × 6 = 67.746 = 0.775
-
Trend line and r²
ŷ = 2.2 + 0.6x r2 = 0.775² = 0.6
What it means: there's a strong positive relationship. Each extra $1,000 of ad spend goes with about $600 more in weekly sales on average, and the line explains 60% of the week-to-week variation in sales. With only five weeks of data, though, the shop should collect more before drawing firm conclusions. Click Load example in the tool above to try a larger data set.
How to read a scatter plot
Look at four things, in this order:
- Direction. If the dots rise from left to right, the relationship is positive (r > 0). If they fall, it's negative (r < 0).
- Form. Do the points follow a straight line, a curve, or no pattern at all? The correlation coefficient and trend line only describe straight-line relationships.
- Strength. The tighter the points cluster around the line, the stronger the relationship and the closer r is to 1 or −1.
- Unusual points. A single outlier can pull the line and change r a lot. Check whether it's a data-entry mistake before removing it.
A common rule of thumb for the size of r (ignoring the sign):
| |r| | Strength of the linear relationship |
|---|---|
| 0 to 0.19 | Very weak or none |
| 0.20 to 0.39 | Weak |
| 0.40 to 0.59 | Moderate |
| 0.60 to 0.79 | Strong |
| 0.80 to 1 | Very strong |
The slope is often the most useful number in practice: it tells you how much y changes, on average, for each one-unit increase in x, in the units you measured. And r² tells you how much of the spread in y the line accounts for. Remember that even a very strong correlation doesn't prove that x causes y.