How to Create an Excel Scatter Chart with Trendline Equation and R-Squared
Question details
The user needs to display a trendline equation and R-squared value on a scatter chart, calculate slope and intercept using formulas, and prevent errors caused by blank cells.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Visualizing data correlations and calculating regression metrics like slope, intercept, and R-squared while handling empty data gracefully.
- Observed behavior
- The user wants to successfully generate a scatter plot with a visible equation and R-squared value, along with error-free formula calculations for regression data.
Ensure your data is organized into two adjacent columns (X values and Y values) and check for any blank cells or non-numeric characters that might disrupt your chart calculations.
Display Equation and R-Squared on the Scatter Chart
Use Excel's built-in chart tools to instantly add a trendline, its mathematical equation, and the R-squared value to your scatter plot.
This method is the most visually intuitive way to display regression data directly on your chart without needing to write manual formulas in the grid.
Highlight your data columns, navigate to the Insert tab on the ribbon, and select the Scatter Chart icon to generate your graph.
Click anywhere on the chart, click the Chart Elements (+) button that appears on the top right of the chart, and check the 'Trendline' box.
Click the small arrow next to Trendline, choose 'More Options', and the Format Trendline pane will open on the right side of your screen.
Scroll to the bottom of the Format Trendline pane and check both 'Display Equation on chart' and 'Display R-squared value on chart'.

Calculate Slope, Intercept, and R-Squared Using Formulas
Extract the exact values for slope, intercept, and R-squared into your spreadsheet cells while avoiding errors from blank data points.
Easily Create Scatter Charts and Calculate Trendlines with WPS Office
WPS Office Spreadsheet provides a seamless and intuitive experience for plotting scatter charts, adding trendlines, and extracting regression formulas. It is a powerful, free alternative that perfectly handles complex data visualization.
- 1. Insert Scatter Chart: Highlight your data, navigate to the Insert tab, and select the Scatter Chart icon from the charts group.
- 2. Add a Trendline: Right-click a data point on the generated chart and choose 'Add Trendline' from the context menu.
- 3. Show Equation and R-Squared: In the formatting pane on the right side, check the boxes for 'Display Equation on chart' and 'Display R-Squared value on chart'.
- 4. Apply Formula Functions: Use =IFERROR(SLOPE(Y_range, X_range), "") in a cell to safely calculate the regression slope without formula errors.

Frequently Asked Questions
Why is my scatter chart starting at zero when my data is clustered in the hundreds?
By default, spreadsheet applications may start chart axes at zero. To fix this, right-click the axis, select Format Axis, and adjust the Minimum value under Axis Bounds to a number closer to your lowest data point.
What does the R-squared value on a trendline mean?
The R-squared value represents the proportion of the variance for a dependent variable that is explained by an independent variable. A value closer to 1 indicates a stronger fit for the trendline to the data points.
Why do the SLOPE and INTERCEPT functions return a #DIV/0! or #VALUE! error?
These errors typically occur if your data ranges contain text, have an unequal number of rows, or include blank cells. Wrapping your formulas in an IFERROR function helps suppress these errors by returning a blank space instead.
Can I format the numbers in the displayed trendline equation?
Yes. Click directly on the trendline equation box in the chart to select it, go to the Format Trendline Label pane, and change the Number category to format decimal places or switch to scientific notation.




