To add a line of best fit in Excel for Microsoft 365 on Windows, select a chart, then choose Chart Design > Add Chart Element > Trendline > Linear. For a meaningful fit, use an XY (Scatter) chart when both variables are numeric; Excel adds a linear trendline that summarizes their relationship.
What a line of best fit shows
A line of best fit, also called a trendline or regression line, is a line drawn through a set of charted observations to show their overall direction. It does not usually pass through every point. Instead, a linear fit balances the vertical differences between the observed values and the values predicted by the line. Excel’s standard linear trendline is based on least-squares regression, which chooses the line that minimizes the sum of those squared differences.
The line helps answer questions such as whether sales tend to rise as advertising increases, or whether a measured response tends to fall as temperature rises. Its slope describes the direction and rate of the pattern: an upward line indicates a positive association, while a downward line indicates a negative one. The intercept is where the fitted line meets the vertical axis, though that value may have little practical meaning if zero is outside the observed range.
A trendline describes an association in the displayed data; it does not establish that one variable causes the other. A strong-looking line can still be misleading if important variables are omitted, the data are biased, or a few unusual observations dominate the pattern.
Choose the right chart before adding the line
For a standard line of best fit, an XY (Scatter) chart is usually the clearest choice. A scatter chart treats both axes as numeric: each point’s horizontal position comes from its x-value, and its vertical position comes from its y-value. This matters when x-values are measurements, dates at irregular intervals, or other numbers whose spacing carries meaning.
To make one, arrange the independent or explanatory values in one column and the corresponding measurements in another. Select both columns, then choose Insert > Insert Scatter (X, Y) or Bubble Chart and select a scatter option. A scatter chart with markers only is often easiest to interpret; connecting the observations can suggest a sequence or path that may not be part of the data.
A line chart can be appropriate when the horizontal axis represents ordered categories, such as months in a reporting series. But category positions are often treated as equally spaced. If the observations are not evenly spaced in time, or the actual numeric distance between x-values matters, a scatter chart makes that distinction clearer. Check that Excel has assigned the intended column to the x-axis; if it has not, use Chart Design > Select Data to edit the series.
Add a linear trendline in Excel for Windows
- Click the chart, then click the data series whose pattern you want to model. A series is a group of related plotted observations.
- On the ribbon, choose Chart Design > Add Chart Element > Trendline > Linear. If the chart has several series, make sure you selected the correct one before adding the line.
- To show the fitted equation or its R-squared value, right-click the trendline and choose Format Trendline. In the Format Trendline pane, select Display Equation on chart and/or Display R-squared value on chart.
- Use the pane to adjust the line’s appearance or select a different trendline type. You can also set a forecast forward or backward when extending the line is appropriate.
Another route is to select the chart, open Chart Design > Add Chart Element > Trendline, and choose a type. In many chart layouts, the chart’s + (Chart Elements) button also offers Trendline. If the menu is unavailable, check that the chart type supports trendlines and that a data series, rather than only a chart title or axis, is selected.
On Excel for Mac, select the chart and use the Chart Design tab’s Add Chart Element controls; right-clicking the series and choosing Add Trendline is another route in supported versions. Ribbon labels and pane placement can differ slightly by release. Excel for the web may not offer the same controls for adding or editing trendlines, so use the desktop app if the option is missing.
Read the equation and R-squared carefully
When Excel displays a linear trendline equation, it reports the model’s slope and intercept. The slope estimates how much the predicted vertical value changes for a one-unit increase in the horizontal value. For example, if a chart relates hours studied to a test score, a slope of 4 would indicate an estimated increase of four score points for each additional hour within the model’s range. It does not mean every student gains exactly four points.
Suppose a small data set contains x-values of 1, 2, 3, and 4, paired with y-values of 3, 5, 7, and 9. Those points lie exactly on a line: each one-unit increase in x corresponds to a two-unit increase in y, and the line begins one unit above zero. This simple example has no scatter around the fitted line. Real observations usually do, so the line is a summary rather than a rule that every case follows.
R-squared, shown as a value between 0 and 1 for the usual fitted models, indicates how much of the variation in the plotted y-values is accounted for by the model in that data set. A value closer to 1 means the observations lie more closely around the fitted model; a value closer to 0 means the model accounts for less of their variation. R-squared does not prove causation, establish that a model is suitable, or guarantee accurate predictions. A high value can arise from a curved pattern that a linear line does not represent well, and a low value may be normal for noisy real-world measurements.
If the chart equation shows too few digits, right-click the equation label and choose Format Trendline Label. In the formatting pane, adjust the number format or displayed decimal places. Avoid showing excessive precision: extra digits can make estimates look more exact than the data justify.
Choose a trendline type that matches the pattern
A linear trendline is a reasonable starting point when the points follow an approximately straight direction. Excel offers other types for different shapes, but selecting one only because it produces a higher R-squared value can overfit the data.
- Exponential: Can represent a pattern that rises or falls at an increasing rate. It requires positive y-values, so it is not suitable when the series includes zero or negative values.
- Logarithmic: Can represent a rapid change that gradually levels off. It requires positive x-values.
- Polynomial: Can follow one or more bends in the data. Excel lets you choose the order; higher orders can make the line swing sharply and fit random noise rather than a useful underlying pattern.
- Power: Can describe a curved relationship based on a power pattern. It requires positive x- and y-values.
- Moving Average: Smooths short-term fluctuations by averaging a chosen number of neighboring points. It is useful for viewing a time-series pattern, but it is not a regression equation in the same sense as a linear fit.
Compare the candidate line with the points and with what is known about the subject. A more complicated model may fit the observations more closely while being harder to explain and less reliable for new values. Do not extend a curve beyond the measured range simply because Excel makes it possible.
Common problems and how to fix them
- The trendline option is missing: Confirm that a data series is selected and that the chart type supports a trendline. Some chart types, including pie, doughnut, radar, 3-D, and stacked charts, do not support the standard trendline feature. A scatter chart is a useful alternative for numeric pairs.
- The line looks wrong: Check the series and axis assignments. A column containing category labels may have been used as the x-values, or Excel may have plotted the wrong columns together. Use Select Data to inspect the series.
- The line does not match uneven dates: A category-style axis can give observations equal spacing even when actual dates are separated by different amounts. Use a scatter chart with real date values on the x-axis when elapsed time should affect spacing.
- The equation seems to predict an impossible value: The intercept may be outside the observed range, or the trendline may be extrapolating. A fitted line is not automatically meaningful at x-values far from those in the chart.
- Blank cells or unusual points change the result: Check for missing values, data-entry errors, outliers, and inconsistent units. A single extreme observation can pull a least-squares line substantially.
It is also worth checking the plotted points before interpreting the line. A curved pattern, separate clusters, or one influential outlier can be hidden by a single summary line. If the chart’s purpose is to show a general relationship, label both axes with units and keep the observations visible so readers can judge the spread for themselves.
Trendline versus connecting the data points
A trendline and a line connecting observations do different jobs. Connecting lines join successive points in their given order; they can show a time sequence or a path. A trendline summarizes the overall relationship between x and y, regardless of whether the points are adjacent in time. A chart can show both, but overlapping lines may make it harder to see the data, so use clear markers and styling if both are needed.
A trendline is also different from a forecast. Excel can extend some trendlines forward or backward, but that extension is a model-based extrapolation, not new observed data. Forecasting future values requires assumptions about whether the historical pattern will continue. Before using an extension for planning, consider seasonality, changing conditions, and whether the model has been checked against data not used to fit it.
Frequently Asked Questions
How do I add a line of best fit to a scatter plot in Excel?
Select the scatter plot and its data series, then choose Chart Design > Add Chart Element > Trendline > Linear. Right-click the line and choose Format Trendline if you want to show the equation or R-squared value.
Can Excel show the equation of a trendline?
Yes. Open the Format Trendline pane and select Display Equation on chart. The equation label can be repositioned and formatted like other chart labels.
What does R-squared mean on an Excel chart?
It indicates how closely the fitted model accounts for variation in the plotted y-values. It is a measure of fit for those data, not proof of causation or a guarantee that predictions will be correct.
Why can’t I add a trendline to my Excel chart?
The chart type may not support trendlines, or the chart itself rather than a data series may be selected. Try selecting a series in a supported two-dimensional chart, such as an XY scatter chart.
Should I use a line chart or a scatter chart for a best-fit line?
Use a scatter chart when both variables are numeric and the spacing between x-values matters. A line chart is often suitable for ordered categories with regular spacing, such as monthly totals, but it can obscure irregular gaps between observations.
Related
- How to Stop Solver in Excel Without Losing Your Work
- How to Update a Data Validation List in Excel Step by Step
- Change Date Format in Excel for the Web: Step-by-Step
Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.
More in Charts & pivot tables
- Excel Chart Color Based on Value: How to Set It UpYes. In Excel for Microsoft 365 on Windows, the most reliable way to color chart points according to…
- Excel Line Chart With Data Labels: Add and Format ThemTo add data labels to an Excel line chart, select the chart and choose Chart Design > Add…
- Excel Line Chart: Switch X and Y Axes the Right WayIn Excel, a line chart’s Switch Row/Column command changes which data series are plotted; it does not literally…
- Excel Extend Trendline Beyond Data Points?Yes. In Excel for Microsoft 365 on Windows, select the chart, choose Chart Design > Add Chart Element…
- Excel Pivot Chart Zero Values: Why They DisappearYes. An Excel PivotChart can appear to omit zero values because the source contains blanks or text instead…
- Excel Pivot Pie Chart With Slicers: How to Set It UpYes. In Excel for Microsoft 365 on Windows, create a PivotTable, insert a pie PivotChart from it, then…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.