How to Add Vertical Line in Excel Graph (Step-by-Step Guide)

A vertical or horizontal line is the benchmark or reference to highlight a specific point. To add a vertical line in an Excel graph, we need to either modify a combo chart or a vertical error bar.

Vertical or horizontal lines often work as a benchmark for a reference value. Usually, the reference value is the average or a fixed value. These lines in the chart indicate a threshold for the general data.

key takeaways

To add a vertical line in an Excel graph,

➤ Plot the reference value (e.g. average) in the chart.
➤ Select the chart and select Chart Elements >> Error Bars >> Percentage.
➤ Right-click on the vertical error bar and select Format Error Bar.
➤ In the Format Error Bars pane, set the Direction as Both and value to 100.
➤ Remove the horizontal error bar and make necessary formats to make the vertical line representable.

overview image

This tutorial will demonstrate how to add a vertical line in an Excel graph. Excel doesn’t have a direct method of adding vertical lines in a chart. Instead, we can modify the combo chart and error bars to replicate the reference vertical line.

Download Practice Workbook
1

Adding Vertical Line to Categorical Y-Axis Values (Qualitative Data)

Combo charts containing scatter plots and straight lines are available in Excel. We can modify the straight line to mimic the vertical line in the scatter plot. To make the line vertical, we need to create extra coordinates.

Let’s say we want a vertical line at the average value of this bar chart that displays sales in different months.

bar chart showing sales in different months

The vertical line should go through (average, 0) and (average, 1) points.

Steps:

➤ In a separate cell (D3), calculate the average value with the AVERAGE formula.

calculating averages with AVERAGE function

➤ Create a pair of indices for X and Y by repeating the same formula for X and putting 0 and 1 for Y (X contains the same average formula, and Y contains manually inserted 0 and 1).

creating custom x and y pairs

➤ Now, right-click on the chart and select the Select Data option from the context menu.

select data option in the context menu

➤ In the Select Data Source dialog box, select Add under Legend Entries.

add option in select data source dialog box

➤ Give the series a name and insert X values as series values.

inserting x values as new series values

➤ Close the dialog boxes.
➤ Right-click on the chart and select Change Chart Type from the context menu this time.

change chart type option in context menu

➤ Select a Combo chart and select a scatter plot with lines as the secondary series. Then select OK.

selecting scatter plot with lines for the new combo chart

➤ Right-click on the chart and select the Select Data option again.

selecting select data to modify combo chart

➤ Select the second series and the Edit option under the Legend Entries.

the edit option in select data source dialog box

➤ Now select the proper values for the X and Y series in the Edit Series dialog box.

inserting x and y values in the edit series box

➤ The vertical line should be available at this point, but the line should be a bit off. To adjust it perfectly, right-click on the secondary axis and select Format Axis.

opening format axis to modify the vertical line

➤ Select the Maximum bound to 1 in the Format Axis pane, and the vertical line will be set in the bar chart.

inserting 1 as maximum value of the line to add a complete vertical line in excel


2

Adding Vertical Line to Numeric Y-Axis Values (Quantitative Data)

Vertical error bars can be represented as vertical lines in an Excel graph. To do that, we can format the error bar at an average (or any reference point where we want to put a vertical line). Eliminating the horizontal error bar and formatting it can give it the visual appearance, as well as work as an error bar.

Let’s take a scatter plot of ice cream sales compared to different temperatures. We are choosing a scatter plot because it is also good for demonstrating the idea.

scatter plot showing ice cream sales at different temperatures

Steps:

➤ Find the average (or the reference point) of X and Y, where you want to put the vertical line.

finding average of x and y to put the error bar

➤ Right-click on the chart and select the Select Data option from the context menu.

selecting data for the scatter chart

➤ Select Add under Legend Entries.

adding data to put the point for error bars

➤ Select the average values for the new X and Y for the series.

inserting x and y values for the new point in chart

➤ Select the average series and go to Chart Elements >> Error Bars >> Percentage.

selecting percentage error bars from chart elements

➤ Right-click on the vertical error bar and select Format Error Bars from the context menu.

format error bars option for the vertical error bar

➤ Under the Error Bar Options, select Both in Direction and set the Percentage to 100.

selecting both direction and 100% for error bars

➤ Format the error bar to make the vertical line stand out.

making necessary formats to make error bar stand out as vertical line


FAQ

How do I add a vertical line to a specific point on the x-axis?

To add a vertical line to a specific point, you can follow the second method of modifying vertical error bars to make it a vertical line.

We have demonstrated the method for an average point. You can select a specific point before adding the error bar and follow the rest of the method to add a vertical line to that point.

How can I add multiple vertical lines to an Excel graph?

You can select a specific point before modifying its error bar to make a vertical line. You can repeat this process for as many points as you want. If you repeat it for multiple reference points, you can get multiple vertical lines.

How do I format the vertical line (e.g., color, style, thickness)?

Whether or not you formatted an error bar or used combo charts for the error, double-click on the line to access the edit options.

Double-clicking on the line opens the Format Data Point/Format Error Bar pane. Go to the Fill & Line tab under it, and you can get all the customizable options available there.


Conclusion

In this tutorial, we have covered how to add vertical lines in an Excel graph. We have created a combo chart and modified error bars to create the vertical lines. The combo chart method is useful for qualitative data on the vertical axis, like the bar chart. Modifying error bars to mimic the vertical lines can be done for any chart.

Feel free to download the practice workbook and give us your feedback.

ExcelInsider Team
We will be happy to hear your thoughts

Leave a reply

Excel Insider
Logo