Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Add a Straight Line to an Excel Graph

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You can add a straight line to an Excel chart in a few ways, and which one you want depends on what the line is for. If you want a trend line drawn through your data, Excel builds it for you in one click (Chart Design > Add Chart Element > Trendline, or right-click a data series > Add Trendline). If you want a fixed reference line at a specific value, such as a target or a baseline, the reliable method is to plot a separate series on a combo chart as a line while your real data stays as columns or dots, on a secondary or same axis. If you want a plain drawn line that is not tied to data at all, use Insert > Shapes > Line. Menu labels can differ slightly by Excel version, platform and region, but the commands below exist in the desktop versions of Excel for Windows and Mac.

What You'll Need

  • Microsoft Excel on Windows or Mac (the Windows/Mac desktop app has the fullest chart tools; Excel for the web has fewer options, so some steps may be missing there).
  • An existing chart, or data ready to chart. If you are starting from scratch, select your data and use Insert > Charts, or select your data and press Alt+F1 on Windows (F11 creates a chart on its own sheet).
  • For a target or reference line: the numeric value you want the line drawn at, and a spare column in the worksheet to hold it.

Step-by-Step

Method 1: A trend line through your data

  1. Click the chart once to select it. The chart tools appear on the ribbon.
  2. Click a data series in the chart (one of the plotted columns, bars or points) so only that series is selected.
  3. Right-click the series and choose Add Trendline. Alternatively use Chart Design > Add Chart Element > Trendline and pick the type.
  4. In the Format Trendline pane, choose Linear for a straight line. If you want the line to run through the whole plot, leave it as a trend line; if you want it extended beyond your data, set Forward and Backward forecast values in the pane.
  5. On the same pane, tick Display Equation on chart and Display R-squared value on chart if you need the slope and fit. Close the pane when done.

Method 2: A fixed horizontal reference line (target, baseline, average)

  1. Add a helper column next to your data with the same value repeated for every row. For example, if you want a line at 500, type 500 in each cell of that column down to the last data row. Give the column a clear header like Target.
  2. Select the chart. If the helper column is not yet plotted, right-click the chart and choose Select Data, then Add a series and point it at your helper column.
  3. The new series will probably appear as columns or bars. Right-click that series and choose Change Series Chart Type.
  4. In the dialog, set the helper series to a Line type, keep your real data as its original type, and use the Secondary Axis checkbox only if the helper value is on a very different scale than your data. If both are on the same scale, leave it unticked so the line sits at the right height.
  5. Click OK. The series now draws as a straight horizontal line across the plot.
  6. Right-click the line, choose Format Data Series, and set the line style: colour, width, and Dash type (dashed is easier to read as a reference line).
  7. Delete the legend entry for the helper series if it clutters the chart: click the legend, click once on the entry, then press Delete.

Method 3: A freehand straight line via Shapes

  1. Click the chart so it is selected.
  2. Go to Insert > Shapes and choose the straight Line shape.
  3. Hold Shift while dragging so the line stays perfectly straight, then release. Holding Shift is what keeps it level or at a clean angle.
  4. Use Shape Format to set the line colour, weight and arrow ends, and drag the endpoints to reposition it. Note that this line floats over the chart and does not move with the data, so it will shift if the chart is resized or the plot area changes.

Common Mistakes

  • Using a shape line for a target value. It looks straight, but it does not follow the axis scale, so it will be in the wrong place as soon as the chart resizes or the data changes. Use a helper-series line for anything tied to a number.
  • Adding a helper series to a secondary axis by default. That puts the line on a different scale and it appears at a misleading height. Only use the secondary axis when the scales genuinely differ.
  • Forgetting to repeat the value down every row. A single-cell helper column plots one point, not a line.
  • Selecting the whole chart instead of one series before adding a trend line, which can apply it to the wrong series or none.
  • Leaving the legend showing the helper series, which confuses readers into thinking it is real data.

Tips

  • Use a dashed, thinner line for reference values so it reads as a guide, not as data.
  • If your data changes length often, use a formula such as =$D$2 in the helper column so the line value updates automatically when you edit the target cell.
  • For a line at the average of your data, set the helper value to =AVERAGE(range) repeated down the column.
  • Trend lines with a forecast only make sense on a scatter (XY) chart or when your x-axis is numeric; on plain category charts Excel treats categories as evenly spaced, so the trend is approximate.
  • Label the reference line directly with a text box or a data label at one end rather than relying on the legend.

Troubleshooting

The trend line option is greyed out

Trend lines are not available for some chart types, such as stacked charts or 3-D charts. Change the chart type to a standard column, line or scatter chart, then try again.

The helper line is missing or tiny

Check that the helper series has more than one data point and that it is plotted on the same axis as the data. If it is on a secondary axis with a different scale, the line can appear in an unexpected place; remove the secondary axis and try again.

The line is not straight

If your helper column contains slightly different values, Excel draws a zig-zag. Make every cell exactly the same. If you are using Shapes, hold Shift while drawing.

The line moves when you resize the chart

A drawn shape is tied to the chart's position, not its scale. Replace it with a helper-series line so it stays anchored to the axis values.

Nothing updates when the data changes

Click the chart and check the range under Select Data. If the series does not include your new rows, extend the range, or convert the source data to an Excel Table (Ctrl+T on Windows) so the chart grows with new entries.

Frequently Asked Questions

Can I add a vertical straight line?

Yes. Use a second helper column of value 1 and plot it as a bar or column series, or use a scatter chart with a numeric x-axis and add a helper series at a fixed x-value. Shapes also work for a visual vertical line, but again do not follow the scale.

Does adding a trend line change my data?

No. A trend line is a calculated overlay; your worksheet values remain unchanged.

Can I add a line to a pie chart?

No. Pie and doughnut charts do not support trend lines or plotted series in the same way. Use a bar or column chart if you need a reference line.

Why does my trend line not start at the first point?

Trend lines are fitted to all points in the series and may not pass through any single one, especially with scatter data. Set the Intercept in the Format Trendline pane if you need the line forced through a specific value.

Can I do this in Excel for the web?

Basic trend lines are available online, but combo chart control and some formatting options are more limited than in the desktop app. For full control, use Excel on Windows or Mac.

How do I remove the line later?

Select the line and press Delete. For a trend line, click it and press Delete, or use Chart Design > Add Chart Element > Trendline > None. For a helper series, choose Select Data and remove the series.