What it does
A scatter plot puts one measurement on each axis, so every dot is one person, day or object. If the dots drift upward together, the two things move together. A line of best fit sums up that trend in one equation, and it lets you predict a value you did not measure. This page gives you three made-up data sets, a line you can set yourself with two sliders, and the real least-squares line to compare with.
The least-squares line is the one that makes the total of the squared gaps (the residuals) between the dots and the line as small as possible. The number r measures how tightly the dots follow a straight line, from −1 to +1. After this, try histogram builder for single sets of numbers or regression workbench for your own data.
How to use it
- Pick a data set: study time and score, heat and cold drinks, or shoe size and score.
- Move the slope and intercept sliders until your orange dashed line runs through the middle of the dots.
- Press “Show best-fit line”. The green line and the little vertical gaps appear.
- Compare the two totals under the graph. Smaller means closer.
- Tap the graph to add your own dot and see how r and the line change.
What each setting does
- Your slope: how steeply your line rises for each step right.
- Your intercept: where your line crosses the vertical axis at x = 0.
- Show best-fit line: adds the least-squares line and its residuals.
- Reset dots: removes the dots you added.
Worked example
Take the five points (1, 2), (2, 4), (3, 5), (4, 4) and (5, 5). The means are 3 and 4. The best-fit line is y = 0.6x + 2.2 and r is about 0.77, a fairly strong positive link. At x = 6 the line predicts 5.8.
FAQs
Does a high r prove one thing causes the other? No. Hot weather and cold drink sales move together, but a link in data never proves cause on its own.
Why squared gaps? Squaring stops positive and negative gaps from cancelling and makes big misses count more.
Can I use the line far outside the data? Be careful. Predicting well beyond the dots (extrapolating) can go badly wrong.
Where the numbers come from
- Scatter plots, lines of best fit, residuals and the correlation coefficient are standard school statistics (Common Core 8.SP and HS-S-ID.6 to 9). The least-squares formulas are checked on hand-worked data in tests/sci.mjs. All three data sets are made up by fibub for teaching.
Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.
Last updated 2026-11-16.