Adding an equation to your Excel graph
To add an equation to a graph in Excel, right-click the data line on your chart, select Add Trendline, then check the box labeled Display Equation on chart. The equation will appear directly on the graph. This works for most chart types — column charts, line charts, scatter plots — as long as you have a data series plotted.
The equation shows the mathematical relationship between your data points. For a simple line, it displays in the form y = mx + b, where m is the slope and b is the y-intercept. For more complex patterns, Excel can fit polynomial, exponential, or logarithmic equations instead.
Key Takeaways
- Right-click the data series (the line or bars), not the chart background, to access the trendline option.
- The equation appears on the chart itself once you check Display Equation on chart in the trendline dialog.
- You can choose different equation types — linear, polynomial, exponential, power, or logarithmic — depending on the pattern in your data.
- Moving the equation label is done by clicking it once to select it, then dragging it to a new position on the chart.
Step-by-step: Adding a linear equation
Start with a chart that already contains your data plotted. Click anywhere on the chart to select it, then click the data line or bars themselves — not the chart background. Right-click and choose Add Trendline from the menu.
In the Trendline dialog that opens, the Linear option is selected by default. Leave it there for a straight-line equation. At the bottom of the dialog, check the box next to Display Equation on chart. Click Close. The equation will now appear somewhere on your chart, usually near the top.
If the equation overlaps your data or sits in an awkward spot, click it once to select it (you will see small squares at the corners), then drag it to a clearer location. You can also right-click the equation text to format its font, size, or color.
Choosing the right equation type for your data
Excel offers five trendline types, each showing a different mathematical pattern. Linear is the most common — it assumes your data follows a straight line and produces an equation like y = 2x + 5. Use this when your values increase or decrease at a steady rate.
Polynomial equations fit curved patterns. You choose the degree (2 for a gentle curve, 3 for more bends, and higher for complex shapes). Exponential equations work for data that grows or shrinks rapidly, like population growth or radioactive decay. Power equations describe relationships where one variable is proportional to another raised to a power. Logarithmic equations fit data that rises quickly at first, then levels off.
To pick the best fit, look at your plotted points. If they roughly form a straight line, use linear. If they curve, try polynomial with degree 2 first. If one end shoots upward or downward steeply, try exponential. Excel does not automatically choose the best type, so you may need to test a few and see which equation looks most reasonable for your data.
Displaying the R-squared value alongside the equation
The R-squared value (also called R²) tells you how well the equation fits your actual data. A value close to 1 means the equation describes your data very accurately. A value close to 0 means the equation is a poor fit. To show this number on your chart, right-click the trendline again and choose Add Trendline.
In the dialog, check the box for Display R-squared value on chart. Click Close. Both the equation and the R² value will now appear on your chart. This is useful when you are deciding between different equation types — the one with the highest R² value usually fits best.
Moving and formatting the equation text
Once the equation appears on your chart, you can reposition it by clicking it once (not double-clicking) to select it, then dragging it anywhere on the chart. The equation stays attached to the chart and moves with it if you resize or move the entire chart.
To change how the equation looks, right-click it and select Format Trendline Label. You can adjust the font, size, color, and background. Some users prefer a white background box behind the equation text to make it stand out from the data. You can also rotate the text if it needs to fit in a tight space, though this is rarely necessary.
Removing an equation from your chart
If you no longer want the equation displayed, right-click it directly and select Delete. The trendline itself stays on the chart — only the equation text is removed. If you want to remove the trendline entirely, right-click the line and choose Delete Trendline.
You can also turn off the equation display without deleting the trendline. Right-click the trendline, select Add Trendline, and uncheck Display Equation on chart. This keeps the visual line on your chart but hides the formula.
Common issues and fixes
If the Add Trendline option is grayed out, you likely clicked the chart background instead of the data series itself. Click directly on a data point, bar, or line, then right-click again. Some chart types, like pie charts, do not support trendlines at all.
If the equation shows very small or very large numbers with many decimal places, it is still correct — Excel is just displaying the full precision. You can format the equation text to show fewer decimals by right-clicking it and adjusting the number format, though this does not change the actual calculation Excel uses.
If your equation looks wrong or does not match your data visually, check that you selected the correct trendline type. A linear equation will never fit curved data well. Switch to polynomial or another type and compare the R² values to find the better fit.
Frequently Asked Questions
Can I add multiple equations to the same chart?
Yes. If you have multiple data series on one chart, you can add a trendline and equation to each one. Right-click each data series separately and repeat the process. Each equation will display independently, though you may need to move them around so they do not overlap.
What does the equation actually tell me?
The equation describes the mathematical relationship between your x-axis and y-axis values. For a linear equation like y = 2x + 5, it means for every unit increase in x, y increases by 2 units, and when x is zero, y starts at 5. You can use this equation to predict values outside your data range.
Why is my equation so complicated?
If you chose a high-degree polynomial or a complex equation type, the formula will have many terms. A simpler equation type (like linear) produces shorter formulas but may not fit your data as well. Check the R² value — if it is high with a simpler equation, use that instead of a complicated one.
Can I copy the equation into a cell for calculations?
You can manually type the equation values into a cell formula, but Excel does not automatically link the chart equation to a cell. If you need to use the equation for calculations, it is faster to create a trendline in a separate analysis or use Excel's FORECAST function with your data.
Does the equation update if I change my data?
Yes. If you add, remove, or modify data points in your chart, the trendline and its equation recalculate automatically. The equation on the chart will update to reflect the new data relationship.