Adding a vertical line in a Line Graph.

On a 2-Axis graph, how to add a reference vertical line on the x-axis. I know you can go to shapes and add a line. However, I do not want to be adjusting the line every time I enter data. I want the reference line to be embedded in the graph. Thank you.

Posted on Sep 23, 2023 1:42 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 23, 2023 6:19 PM

The only chart that allows a vertical reference line as part of the chart is the scatter chart because it is the only one where the X axis is actual numeric data. For all other x-y charts, the X axis is evenly spaced data points with text labels. If you really mean how to add "a vertical line in a Line Graph", you might be able to use the scatter chart. You cannot if you are using a mixed 2-axis chart like in your screenshot.


One option is to use two overlapping charts. Below is an example of the two charts before dragging the "reference line" bar chart overtop the other and then deleting the common/overlapping elements (axis lines, axis labels, gridlines, etc.). The line width of the reference line is dependent on the number of x axis categories and the width of the chart. More categories and narrower chart will make the line more narrow. What you see below is the narrowest I could make it for this particular chart. This is not a perfect solution because it requires you to work with two charts. If you make a change to your data or table that requires an adjustment in the chart (changing the min, max, the ranges for the series, etc.) you'll be doing some things twice.


5 replies
Question marked as Top-ranking reply

Sep 23, 2023 6:19 PM in response to CRainier

The only chart that allows a vertical reference line as part of the chart is the scatter chart because it is the only one where the X axis is actual numeric data. For all other x-y charts, the X axis is evenly spaced data points with text labels. If you really mean how to add "a vertical line in a Line Graph", you might be able to use the scatter chart. You cannot if you are using a mixed 2-axis chart like in your screenshot.


One option is to use two overlapping charts. Below is an example of the two charts before dragging the "reference line" bar chart overtop the other and then deleting the common/overlapping elements (axis lines, axis labels, gridlines, etc.). The line width of the reference line is dependent on the number of x axis categories and the width of the chart. More categories and narrower chart will make the line more narrow. What you see below is the narrowest I could make it for this particular chart. This is not a perfect solution because it requires you to work with two charts. If you make a change to your data or table that requires an adjustment in the chart (changing the min, max, the ranges for the series, etc.) you'll be doing some things twice.


Sep 24, 2023 2:09 PM in response to CRainier

If they do add vertical reference lines to line/bar/mixed charts, the lines will be only at the center of the labels like the bar I made in the example. The X axis is text. There are no averages, medians, means, or numeric values from which to locate reference lines, only the textual labels.


I thought of another way to do the reference line for your 2-axis chart. This one is all in the one chart.



  1. Put a 0 in the 3rd data column of the table wherever you want a reference line.
  2. Include the third column as a third series on the chart. Set the data symbols and the connection lines to "none" for this series. I set the series to plot on the Y1 axis but it doesn't really matter except in the next step where it might change what numbers you use.
  3. Set up custom error bars for the series. Set the positive so the line goes to the top of the chart and the negative so it goes to the bottom.
  4. Click on the error bar and change the shape to be straight (not bars at the ends) and the color you want. You can also change the width.


Note: To select the series in the chart so you can edit things about it, click on Edit References then click on the colored area at the top of the series in the table.


If your chart min or max changes, you will have to adjust the pos and/or neg of the error bars.


If you want multiple reference lines of different colors, you'll have to use a series for each color.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Adding a vertical line in a Line Graph.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.