Scatter Plot Maker with Line of Best Fit

Paste your x and y values to get a scatter plot with the line of best fit, its equation, the correlation coefficient r and R². You can also show residuals, draw a residual plot, predict new values and download the graph as a PNG or SVG.

Your data

Add at least 2 points.

Examples:

Your scatter plot

Your scatter plot appears here as you type.

How to use the scatter plot maker

  1. Type one point per line as x, y, or paste two columns straight from Excel or Google Sheets. If your data is in two separate lists, use the “Two lists” tab.
  2. Add a title and axis labels so the graph is ready for homework or a report.
  3. Read the line of best fit equation, the correlation coefficient \(r\) and \(R^2\) under the graph. Type an x value to predict y.
  4. Turn on “Show residuals” or “Residual plot” to check how well the line fits, then download the graph as a PNG or SVG.

How to make a scatter plot by hand

A scatter plot shows the relationship between two variables measured on the same things, for example hours studied and test score for each student. Put the explanatory variable (the one you think does the influencing) on the x-axis and the response variable on the y-axis.

  1. Choose a scale for each axis that covers the smallest and largest values.
  2. Plot one dot for each pair \((x, y)\). Do not join the dots.
  3. Describe the pattern: its direction (positive or negative), its form (straight or curved), its strength, and any unusual points.

The line of best fit formula

The calculator uses the least squares regression line, \(\hat{y} = mx + b\). It is the line that makes the sum of the squared residuals as small as possible. The slope and intercept are:

\[ m = \frac{\sum (x – \bar{x})(y – \bar{y})}{\sum (x – \bar{x})^2}, \qquad b = \bar{y} – m\bar{x} \]

Here \(\bar{x}\) and \(\bar{y}\) are the means of the x and y values. The line always passes through the point \((\bar{x}, \bar{y})\). In AP Statistics the same line is often written \(\hat{y} = a + bx\), with \(b = r\dfrac{s_y}{s_x}\) as the slope.

Worked example: the points \((1, 2)\), \((2, 4)\), \((3, 5)\), \((4, 4)\), \((5, 5)\). The means are \(\bar{x} = 3\) and \(\bar{y} = 4\). Then \(\sum (x-\bar{x})(y-\bar{y}) = 4 + 0 + 0 + 0 + 2 = 6\) and \(\sum (x – \bar{x})^2 = 10\), so \(m = 0.6\) and \(b = 4 – 0.6(3) = 2.2\). The line of best fit is \(\hat{y} = 0.6x + 2.2\).

Correlation coefficient r and R squared

The correlation coefficient measures how closely the points follow a straight line. It is always between \(-1\) and \(1\):

\[ r = \frac{\sum (x – \bar{x})(y – \bar{y})}{\sqrt{\sum (x – \bar{x})^2 \sum (y – \bar{y})^2}} \]

Value of \(r\)What it means
\(0.8\) to \(1\)Strong positive linear correlation
\(0.5\) to \(0.8\)Moderate positive
\(0.3\) to \(0.5\)Weak positive
\(-0.3\) to \(0.3\)Very weak or no linear correlation
\(-0.5\) to \(-0.3\)Weak negative
\(-0.8\) to \(-0.5\)Moderate negative
\(-1\) to \(-0.8\)Strong negative linear correlation

\(R^2\) is \(r\) squared. It is the fraction of the variation in y that the line explains. An \(R^2\) of 0.81 means the line explains about 81% of the variation in y. These cut-offs are a common rule of thumb, and some textbooks use slightly different ones.

Residuals and the residual plot

A residual is the actual value minus the predicted value, \(e = y – \hat{y}\). A positive residual means the point is above the line. A residual plot puts the x values on the horizontal axis and the residuals on the vertical axis.

If the residuals are scattered randomly above and below zero with no pattern, a straight line is a good model. If they form a curve, the relationship is not linear, so a straight line is the wrong model even when \(r\) looks high.

Frequently asked questions

How do I find the line of best fit?

Enter your points and the calculator draws the least squares line and gives its equation \(\hat{y} = mx + b\). By hand, find the means, then use \(m = \dfrac{\sum (x – \bar{x})(y – \bar{y})}{\sum (x – \bar{x})^2}\) and \(b = \bar{y} – m\bar{x}\).

What is a good r value?

Values close to \(1\) or \(-1\) show a strong linear relationship. As a rule of thumb, \(|r| \ge 0.8\) is strong, 0.5 to 0.8 is moderate, and below 0.3 there is little or no linear correlation.

Does correlation mean causation?

No. A strong correlation shows that two variables move together, not that one causes the other. Both may be driven by a third variable. Ice cream sales and sunburns rise together because of hot weather, not because one causes the other.

Can I predict values outside my data?

You can, but be careful. Predicting outside the range of your x values is called extrapolation, and the pattern may not continue. The calculator warns you when you do this.

How do I paste data from Excel or Google Sheets?

Select the two columns (x first, then y), copy them, and paste into the box. Each row becomes one point. Your data stays in your browser and is not uploaded.

Related tools and practice