How to Add Trendline Equations and R-Squared Values to Excel Legends
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.

- 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.
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.
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.
Right-click on an empty area of your chart and select 'Select Data' from the context menu.
In the Select Data Source window, click the 'Add' button under the 'Legend Entries (Series)' section.
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'.
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.

Manually Position the Equation Label Near the Legend
Generate the standard equation label and visually align it with the legend area to simulate a unified look.
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. Insert Your Chart: Highlight your dataset in WPS Spreadsheet, go to the 'Insert' tab, and choose your preferred chart type.
- 2. Add a Trendline: Click the inserted chart to reveal the 'Chart Elements' shortcut, then select 'Trendline' to apply it to your data.
- 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. Format for Clarity: Drag the resulting label box near your legend or desired area to ensure your chart remains easy to read.

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.




