logo
search
Chart & Visualization Issues

How to Add Trendline Equations and R-Squared Values to Excel Legends

Olivia MillerOlivia Miller Oct 16, 2026 868 views

Question details

The user wants to display the trendline equation and R-squared value directly inside the chart legend rather than as separate floating labels on the chart.

How to Add Trendline Equations and R-Squared Values to Excel Legends
Product
Microsoft Excel
Device & OS
not provided
Scenario
Creating data visualizations and statistical charts where the trendline equation and R-squared information need to be clearly presented within the legend.
Observed behavior
Excel automatically places trendline equations and R-squared values as floating text boxes on the chart area, with no native automatic option to embed them directly into the legend entries.
Before you start

Ensure your chart already has a trendline applied. Since Excel does not natively support moving these equations into the legend automatically, prepare to use manual formatting or a dummy data series as a workaround.

Solution 1Recommended

Create a Custom Dummy Data Series for the Legend

Use a hidden data series with a custom name to force the trendline equation to appear as a standard entry in your chart's legend.

Because Excel builds the legend based on the names of the data series, you can create a fake data series that contains no visible lines or markers, but uses your desired equation as its name.

1
Open the Select Data Source Dialog

Right-click on an empty area of your chart and select 'Select Data' from the context menu.

2
Add a New Data Series

In the Select Data Source window, click the 'Add' button under the 'Legend Entries (Series)' section.

3
Input the Equation as the Series Name

In the 'Series Name' field, manually type your trendline equation and R-squared value (e.g., 'y = 2x + 1, R² = 0.95'). Leave the 'Series Values' blank or set to a single zero, then click 'OK'.

4
Hide the Dummy Series on the Chart

Select the newly added data point on the chart (if visible). Right-click it, choose 'Format Data Series', and set both the Line and Marker options to 'No line' and 'None'. Your equation will now appear cleanly in the legend.

Create a Custom Dummy Data Series for the Legend
Manual Updates Required: Because this text is manually typed, you will need to update the series name yourself if the underlying data changes and produces a new trendline equation.
Advanced Data Visualization

Easily Add Trendlines and Equations in WPS Spreadsheet

WPS Spreadsheet offers a highly compatible and intuitive tool for your data visualization needs. You can easily insert charts, add trendlines, and display equations to make your statistical analysis clear and professional without the heavy processing demands.

  1. 1. Insert Your Chart: Highlight your dataset in WPS Spreadsheet, go to the 'Insert' tab, and choose your preferred chart type.
  2. 2. Add a Trendline: Click the inserted chart to reveal the 'Chart Elements' shortcut, then select 'Trendline' to apply it to your data.
  3. 3. Show the Equation: Double-click the trendline to open the settings pane on the right. Check the options to display the equation and R-squared value.
  4. 4. Format for Clarity: Drag the resulting label box near your legend or desired area to ensure your chart remains easy to read.
Free and lightweight spreadsheet softwareFully compatible with Microsoft Excel (.xlsx, .xls) formatsRich chart types and intuitive data visualization toolsUser-friendly interface for seamless statistical analysis
microsoft office alternative - wps office

Frequently Asked Questions

Can I automatically link a legend entry to a trendline equation in Excel?

No, Excel does not have a built-in feature to dynamically link a trendline equation to a legend entry. You must use manual text boxes or create a dummy data series to force the equation into the legend space.

Why does the R-squared value appear floating on the chart instead of in the legend?

Excel treats trendline equations and R-squared values as data labels that belong directly to the visual trendline itself, rather than as independent data series that would automatically populate the chart's legend.

How do I update the custom legend if my data changes?

If you used the dummy data series method to display the equation in the legend, it will not update automatically. You must manually right-click the chart, choose 'Select Data', edit the dummy series, and type in the newly calculated equation and R-squared value.