DataToPlot

Free online statistics plot makers and calculators.

Line of Best Fit Calculator with Equation

Paste paired X/Y data to calculate a trendline equation, slope, intercept, Pearson r, R², RMSE, residuals, and a fitted line chart.

X/Y data

Paste paired X and Y values, one pair per row. Separators: tabs, commas, spaces, line breaks.

Advanced settings

Chart preview

PNG, SVG, JPG, and JPEG export run locally.

Enter valid data to preview the chart.

Results

Enter valid data to calculate results.

How this tool works

Calculate a fitted line from paired data

Paste paired X/Y values from a spreadsheet-style table or plain text. The calculator uses ordinary least squares to find the fitted line and renders it on top of the scatter plot.

  • Use one row per pair when copying data from a spreadsheet.
  • Read the equation in y = mx + b form with slope and intercept.
  • Enable the residual plot when you want to inspect model fit.

Read slope, R², RMSE, and residuals

The slope is the expected change in Y for one unit of X. The intercept is the predicted Y value when X is zero. R² estimates how much variation in Y is explained by the fitted line.

  • Pearson r shows direction and strength of the linear relationship.
  • RMSE summarizes typical prediction error in Y units.
  • Large standardized residuals can flag possible outliers.

When a line of best fit is useful

A line of best fit is useful when the scatter plot has an approximately linear pattern. With the sample data, Y increases steadily as X increases, so the fitted line has a positive slope and the residual table shows how far each point sits above or below that line.

How to read regression results

The slope shows how much the predicted Y value changes for a one-unit increase in X. The intercept is the predicted Y value when X is zero, which is useful when zero is inside the meaningful range of your data.

Pearson r describes the direction and strength of the linear relationship. R² is r squared and estimates how much variation in Y is explained by the fitted line. RMSE summarizes the typical prediction error in Y units, so smaller values usually mean the points are closer to the line.

The residual table compares each observed Y value with the predicted value. Standardized residuals make unusually large errors easier to spot; values with an absolute standardized residual above 2 are marked as potential outliers.

Related tools

FAQ

Can I paste data directly from a spreadsheet?

Yes. Copy two numeric columns from a spreadsheet and paste them into the input area. Tab-separated data is supported.

Is my data uploaded to a server?

No. DataToPlot parses, calculates, and renders charts in your browser.

Which separators are supported?

The tool supports commas, spaces, tabs, and new lines for numeric data.

Can I export the chart?

Yes. After the preview renders, export the chart as PNG, SVG, JPG, or JPEG.

What happens if my data has an invalid value?

The page shows a clear error message with the row where parsing failed.

Does it show the line equation?

Yes. The calculator shows the fitted equation in y = mx + b form, including slope and intercept.

How is the line of best fit calculated?

The calculator uses ordinary least squares simple linear regression.

What does R² mean?

R² is the share of variation in Y explained by the fitted linear model.