Specific line and bar types are available in 2-D stacked bar and column charts, line charts, pie of pie and bar of pie charts, area charts, and stock charts.
Predefined line and bar types that you can add to a chart
Depending on the chart type that you use, you can add one of the following lines or bars:
-
Series lines These lines connect the data series in 2-D stacked bar and column charts to emphasize the difference in measurement between each data series. Pie of pie and bar of pie charts display series lines by default to connect the main pie chart with the secondary pie or bar chart.
-
Drop lines Available in 2-D and 3-D area and line charts, these lines extend from data points to the horizontal (category) axis to help clarify where one data marker ends and the next data marker starts.
-
High-low lines Available in 2-D line charts and displayed by default in stock charts, high-low lines extend from the highest value to the lowest value in each category.
-
Up-down bars Useful in line charts with multiple data series, up-down bars indicate the difference between data points in the first data series and the last data series. By default, these bars are also added to stock charts, such as Open-High-Low-Close and Volume-Open-High-Low-Close.
Add predefined lines or bars to a chart
-
Click the 2-D stacked bar, column, line, pie of pie, bar of pie, area, or stock chart to which you want to add lines or bars.
This displays the Chart Tools, adding the Design, Layout, and Format tabs.
-
On the Layout tab, in the Analysis group, do one of the following:
-
Click Lines, and then click the line type that you want.
Note: Different line types are available for different chart types.
-
Click Up/Down Bars, and then click Up/Down Bars.
-
Tip: You can change the format of the series lines, drop lines, high-low lines, or up-down bars that you display in a chart by right-clicking the line or bar, and then clicking Format <line or bar type> .
Remove predefined lines or bars from a chart
-
Click the 2-D stacked bar, column, line, pie of pie, bar of pie, area, or stock chart that displays predefined lines or bars.
This displays the Chart Tools, adding the Design, Layout, and Format tabs.
-
On the Layout tab, in the Analysis group, click Lines or Up/Down Bars, and then click None to remove lines or bars from a chart.
Tip: You can also remove lines or bars immediately after you add them to the chart by clicking Undo on the Quick Access Toolbar or by pressing CTRL+Z.
You can add other lines to any data series in an area, bar, column, line, stock, xy (scatter), or bubble chart that is 2-D and not stacked.
Add other lines
-
This step applies to Word for Mac only: On the View menu, click Print Layout.
-
In the chart, select the data series that you want to add a line to, and then click the Chart Design tab.
For example, in a line chart, click one of the lines in the chart, and all the data marker of that data series become selected.
-
Click Add Chart Element, and then click Gridlines.
-
Choose the line option that you want or click More Gridline Options.
Depending on the chart type, some options may not be available.
Remove other lines
-
This step applies to Word for Mac only: On the View menu, click Print Layout.
-
Click the chart with the lines, and then click the Chart Design tab.
-
Click Add Chart Element, click Gridlines, and then click More Gridline Options.
-
Select No line.
You can also click the line and press DELETE .
Home / Excel Charts / Add a Horizontal Line in a Chart
While creating a chart in Excel, you can use a horizontal line as a target line or an average line. It can help you to compare achievement with the target. Just look at the below chart.
You like it, right? Say “Yes” in the comment section if you like it. OK so listen: Let’s say you have an average value which you want to maintain in your sales throughout the year. Or, a constant target which you want to show in a chart for all the months.
In this case, you can insert a straight horizontal line to present that value. Here’s the thing: This horizontal line can be a dynamic one that will change its value or a line with a fixed value. And in today’s post, I’m going to show you exactly how to do this.
I’m gonna share with you that how you can insert a fixed as well as a dynamic horizontal line in a chart.
An average line plays an important role whenever you have to study some trend lines and the impact of different factors on-trend. And before you create a chart with a horizontal line you need to prepare data for it.
Before I tell you about these steps let me show how I am setting up the data. Here I am using a dynamic chart to show you that how this will help you to make your presentation super cool. (download this dynamic data table from here) to follow along.
In the above data tables, I am getting data from the raw table to the dynamic table by using a VLOOKUP MATCH. Every time when I change the year in the dynamic table it will automatically change the sales values and the average will be calculated on those sale figures.
Below are the steps you need to follow to create a chart with a horizontal line.
- First of all, select the data table and insert a column chart.
- Go To Insert ➜ Charts ➜ Column Charts ➜ 2D Clustered Column Chart. or you can also use Alt + F1 to insert a chart.
- So now, you have a column chart in your worksheet like below.
- Next step is to change that average bars into a horizontal line.
- For this, select the average column bar and Go to → Design → Type → Change Chart Type.
- Once you click on change chart type option, you’ll get a dialog box for formatting.
- Change the chart type of average from “Column Chart” to “Line Chart With Marker”.
- Click OK.
Here is your ready-to-rock column chart with an average line and make sure to download this sample file from here.
One of my colleagues uses this same method to add a median line. You can also use this method to add an average line in a line chart. The steps are totally the same, you just have to insert a line chart instead of a column chart. And you will get something like this.
Add a Horizontal Target Line in Column Chart
This is one more method which I often use in my charts is adding a target line. There are several other ways to create a Target Vs. Achievement chart, but target line method is simple & effective. First of all, let me show you the data which I am using to create a target line in the chart.
I have used the above table to get the target and actual figures from the month-wise tables and make sure to download the sample file from here. Now let’s start with the steps.
- Select the dynamic table which I have mentioned above.
- Insert a column chart. Go To Insert → Charts → Column Charts → 2D Clustered Column Chart.
- You’ll get a chart like below.
- Now, you have to change the chart type of target bar from Column Chart to Line Chart With Markers. To change the chart type please use same steps which I have used in the previous method.
- After changing chart type your chart will look something like this.
- Now, we have to make some changes in this line chart.
- After that, make a double click on the line to open formatting option. Once you do that, you’ll get a formatting option dialog box.
- Make following changes in formatting.
- Go to → Fill & Line → Line.
- Change line style to “No Line”.
- Now, go to marker section and make following changes.
- Change marker type to Built-In, a horizontal bar, and size 25.
- Marker fill to solid fill.
- Use white color as the fill color.
- Make border style to a solid color.
- And, black color for borders.
- Once you make all the changes to the line you’ll get a chart like I have below.
Congratulations! your chart is ready.
Sample File
Download this sample file from here to follow along
More Charting Tutorials
Tuesday, September 11, 2018
Peltier Technical Services, Inc., Copyright © 2023, All rights reserved.
A common task is to add a horizontal line to an Excel chart. The horizontal line may reference some target value or limit, and adding the horizontal line makes it easy to see where values are above and below this reference value. Seems easy enough, but often the result is less than ideal. This tutorial shows how to add horizontal lines to several common types of Excel chart.
We won’t even talk about trying to draw lines using the items on the Shapes menu. Since they are drawn freehand (or free-mouse), they aren’t positioned accurately. Since they are independent of the chart’s data, they may not move when the data changes. And sometimes they just seem to move whenever they feel like it.
The examples below show how to make combination charts, where an XY-Scatter-type series is added as a horizontal line to another type of chart.
An XY Scatter chart is the easiest case. Here is a simple XY chart.
Let’s say we want a horizontal line at Y = 2.5. It should span the chart, starting at X = 0 and ending at X = 6.
This is easy, a line simply connects two points, right?
We set up a dummy range with our initial and final X and Y values (below, to the left of the top chart), copy the range, select the chart, and use Paste Special to add the data to the chart (see below for details on Paste Special).
When the data is first added, the autoscaled X axis changes its maximum from 6 to 8, so the line doesn’t span the entire chart. We have to format the axis and type 6 into the box for Maximum. We probably also want to remove the markers from our horizontal line.
Paste Special
If you don’t use Paste Special often, it might be hard to find. If you copy a range and use the right click menu on a chart, the only option is a regular Paste, and Excel doesn’t always correctly guess how it should paste the data. So I always use Paste Special.
To find Paste Special, click on the down arrow on the Paste button on the Home tab of Excel’s ribbon. Paste Special is at the bottom of the pop-up menu.
You can also use the Excel 97-2003 menu-based shortcut, which is Alt + E + S (for Edit menu > Paste Special).
The tooltip below Paste Special in the menu indicates that you could also use Ctrl + Alt + V, but this shortcut doesn’t do anything for charts.
When the Paste Special dialog appears, make sure you select these options: Add Cells as a New Series, Y Values in Columns, Series Names in First Row, Categories (X Values) in First Column.
Click OK and the new series will appear in the chart.
Add a Horizontal Line to a Column or Line Chart
When you add a horizontal line to a chart that is not an XY Scatter chart type, it gets a bit more complicated. Partly it’s complicated because we will be making a combination chart, with columns, lines, or areas for our data along with an XY Scatter type series for the horizontal line. Partly it’s complicated because the category (X) axis of most Excel charts is not a value axis.
As with the XY Scatter chart in the first example, we need to figure out what to use for X and Y values for the line we’re going to add. The Y values are easy, but the X values require a little understanding of how Excel’s category axes work. Since the category axes of column and line charts work the same way, let’s do them together, starting with the following simple column and line charts.
Note in the charts above that the first and last category labels aren’t positioned at the corners of the plot area, but are moved inwards slightly. This is because column and line charts use a default setting of Between Tick Marks for the Axis Position property. We can change the Axis Position to On Tick Marks, below, and the first and last category labels line up with the ends of the category axis. The line chart looks okay, but we have cut off the outer halves of the first and last columns.
Let’s focus on a column chart (the line chart works identically), and use category labels of 1 through 5 instead of A through E. Excel doesn’t recognize these categories as numerical values, but we can think of them as labeling the categories with numbers.
Now let’s label the points between the categories. Not only do we have halfway points between the categories, we also have a half category label below the first category and another after the last category.
If the Axis Position property were set to On Tick Marks, our horizontal line starts at 1 (the first category number of 1) and ends at 5 (the last category number of 5). This would be wrong for a column chart, but might be acceptable for a line chart.
Here is our desired horizontal line, stretching from 0.5 to 5.5
So let’s use this data and the same approach that we used for the scatter chart, at the beginning of this tutorial.
Copy the range, and paste special as new series. We’ve added another set of columns or another line to the chart.
Right click on the added series, and choose Change Series Chart Type from the pop-up menu.
In the Change Chart Type dialog, select the XY Scatter With Straight Lines And Markers chart type. We’re using markers to temporarily mark the ends of the line, and we’ll remove the markers later; in general we will change directly to XY Scatter With Straight Lines.
The new series don’t line up at all, though, because Excel decided we should plot the scatter series on the secondary axes. We could rescale the secondary axes, then hide them, but that makes a complicated situation even more complicated.
So we need to uncheck the Secondary Axis box next to the Scatter series in the Change Chart Type dialog.
And now everything lines up as expected: the markers on the horizontal lines are at the edges of the plot area.
We should remove those markers now, and in the future select the chart type without markers.
“Lazy” Horizontal Line
You may ask why not make a combination column-line chart, since column charts and line charts use the same axis type. And many charts with horizontal lines use exactly this approach. I call it the “lazy” approach, because it’s easier, but it provides a line that doesn’t extend beyond all the data to the sides of the chart.
Start with your chart data, and add a column of values for the horizontal line. You get a column chart with a second set of columns, or a line chart with a second line.
Change the chart type of the added series to a line chart without markers. Doesn’t look very good for the column chart (left) since the horizontal line ends at the centerlines of the first and last column. You could probably get away with it for the line chart, even though the horizontal line doesn’t extend to the sides of the chart.
If we change the Axis Position so the vertical axis crosses On Tick Marks, the horizontal lines for both charts span the entire chart width. In the column chart, this comes at the expense of the outer halves of the first and last columns. The line chart looks okay, though.
Add a Horizontal Line to an Area Chart
As with the previous examples, we need to figure out what to use for X and Y values for the line we’re going to add. The category axis of an area chart works the same as the category axis of a column or line chart, but the default settings are different. Let’s start with the following simple area chart.
Notice that the first and last category labels are aligned with the corners of the plot area and the filled area series extends to the sides of the plot area. This is because the default setting of the Axis Position property is On Tick Marks. We can change it to Between Tick Marks, which makes the area chart look a bit strange.
Below is the data for our horizontal line, which will start at 1 (the first category number of 1) and end at 5 (the last category number of 5), without the half-category cushion at either end. Copy the data, select the chart, and Paste Special to add the data as a new series.
Right click on the added series, and change its chart type to XY Scatter With Straight Lines And Markers (again, the markers are temporary). The resulting line extends to the edges of the plotted area, but Excel changed the Axis Position to Between Tick Marks.
Change the Axis Position setting back to On Tick Marks, and remove the markers from the line.
“Lazy” Horizontal Line
In the column chart, and perhaps for the line chart, the “lazy” approach did not give a suitable horizontal line, since the line did not extend to the edges of the plot area. Let’s see how it works for an area chart.
Make a chart with the actual data and the horizontal line data.
Right click on the second series, and change its chart type to a line. Excel changed the Axis Position property to Between Tick Marks, like it did when we changed the added series above to XY Scatter.
Change the Axis Position back to On Tick Marks, and the chart is finished.
For the area chart, the appearance of the lazy horizontal line is identical to the more complicated line that uses an XY Scatter series. Since it’s easier and just as good, it’s probably better to use the lazy approach.
Follow-Up
An alert reader noted in the comments that the line produced by this method is placed in front of the bars, and it might be better to place such reference lines behind the data. I have written a new post describing an approach that does just this: Horizontal Line Behind Columns in an Excel Chart.
Historical
I showed similar approaches in an old post, Add a Target Line.
More Combination Chart Articles on the Peltier Tech Blog
- Clustered Column and Line Combination Chart
- Precision Positioning of XY Data Points
- Horizontal Line Behind Columns in an Excel Chart
- Bar-Line (XY) Combination Chart in Excel
- Salary Chart: Plot Markers on Floating Bars
- Fill Under or Between Series in an Excel XY Chart
- Fill Under a Plotted Line: The Standard Normal Curve
- Excel Chart With Colored Quadrant Background
There are a few creative ways to add a vertical line to your chart bouncing around the internet. If you have landed on this article, I assume you are looking for an automated solution so you don’t have to manually drag the line(s) you drew on your spreadsheet every month.
Well, you have come to the right place!
In this article, you will learn the best way to add a dynamic vertical line to your bar or line chart. This technique is fairly easy to implement but took a lot of creative thinking to develop (I definitely did not create this technique but it’s been well known among Excel chartists for decades).
In this article, we’ll cover 3 topics:
-
Embedding Vertical Line Shapes Into A Chart (Simple Method)
-
Creating A Dynamic Vertical Line In Your Chart (Advanced Method)
-
Adding Text Labels Above Your Vertical Line
I do have an example Excel file available to download near the end of this article in case you get stuck on a particular step.
Embedding A Vertical Line Shape Into A Chart
This first method is the quick and dirty way to get a vertical line into your chart. I only recommend this method if this is a single-use chart and you will not have to be moving the vertical line around in the future. You’ll learn a more dynamic methodology in the next section of this article.
Create Your Line
First, you will need to draw a line shape on your spreadsheet. You can do this by navigating to the Insert tab and opening the Shapes menu button.
Select the line button and your cursor should change to be in Draw Mode.
Hold down your SHIFT key on the keyboard and click where you want your line to begin and drag downward to add length to your line.
If your line looks a little slanted, you can ensure the width of the line = 0 to force it to be zero (in the Shape Format tab). If you want to change the length of your line, you can hold the SHIFT key down while you adjust to ensure it remains perfectly vertical.
Format Your Line
You’ll likely want to modify the formatting of your line from the default look. There are many formatting options available to you in the Shape Format tab. This contextual Ribbon tab appears when you have the line shape selected.
For chart lines, I typically modify the following line properties:
-
Line Weight: 2.25 — 3.00 pts
-
Dashes: Rounded Dots
-
Shape Outline Color: Medium/Light Grey
Embed Your Line Into The Chart
Now that you have your vertical line looking the way your want, it’s time to add it to your chart.
Many people will just reposition the line on top of the chart and call it a day. This is really poor practice since the line will not reposition if you happen to move or resize your chart. You will also have to remember to select both the chart and the line objects before copying, to capture the entire chart graphic.
You really should embed the vertical line inside your chart so it becomes part of the chart object. This can be done by:
-
Copy the vertical line shape (CTRL + C)
-
Select the Chart Object
-
Paste (Ctrl + V)
Copy/Paste the Vertical Line into the Chart itself to embed it
Reposition Your Line
After you paste the line into your selected Chart object, you should see the line appear inside the chart. You can then proceed to reposition the line with your mouse. Unfortunately, you cannot use the arrow keys on your keyboard to reposition a shape or textbox embedded in a chart object.
For vertical lines, I recommend making the line start on the X-axis and end at the very top of the Plot Area. The Plot Area is the box that gets outlined in your Chart when you click on the white space between your bars.
To update the position of the vertical line in the future, you just need to remember to move the line inside the chart. We’ll discuss a more advanced technique in the next section which will allow you to automate moving the line across your chart.
Creating A Dynamic Vertical Line In Your Chart
If you are looking for a more automated/long-term solution for incorporating a vertical line into your chart, this is going to be the solution for you.
The technique we’ll be using incorporates a single-pointed Scatter Plot (x,y) in combination with your current chart. The single point charted on the Scatter Plot will control the location of the vertical line.
We will then turn on vertical Error Bars (margin of error indicators), repurposing them to visually display a vertical line on the chart.
Now if that explanation went way over your head, don’t worry! I will walk you through each step and show you it’s really not that difficult to set this up.
Chart Starting Point
I’m going to assume you already have your chart created and you are looking to add the vertical line to the pre-existing chart. With this assumption in mind, I’ll forgo walking you through how to create a chart in Excel.
For this example, we’ll use the below chart to start with and we will work to insert a vertical line to separate the Actual months from the Forecast months.
Create A Combo Chart
The vertical line will need to be plotted using a Scatter Plot chart. Chances are you are working with either a Bar Chart or a Line Chart, so we will need to turn your chart into a Combo Chart. Combo Charts can accommodate different charting types within a single Chart object.
Before you can set up a Combo Chart, your chart will need to have an additional chart series that we can plot to. You can add an additional row of temporary data to your chart data and ensure a new chart series is connected to it (through the Select Chart Data dialog box).
Once your chart has the additional chart series added, select the entire chart and navigate to the Chart Design tab in the Excel Ribbon.
Select the Change Chart Type button to launch the Change Chart Type dialog box. Once the dialog box appears, click on the Combo menu item in the left-side pane.
Look for the series you set up to chart the vertical line and ensure its Chart Type designation is changed to Scatter. Also, make sure the Secondary Axis checkbox remains unchecked.
Once you have made your changes, you can click the OK button to finish converting your chart to a Combo Chart.
Create the Scatter Plot Series
Once you have added Scatter Plot capabilities to your chart, you can then begin to set up your x and y coordinates for your vertical line.
Right-click on your chart and go to Select Data.
Ensure the Series Name you designated as a Scatter Plot series is selected and click the Edit button.
You can then begin to link your X and Y coordinates for your series. In this case, you will want the Y value = 0 and your X value to be halfway between the two bars you wish the vertical line to reside. In this example, since our first forecast month is April, the X value will equal 3.5.
You can hardcode your Y value to zero if you’d like (no cell reference) or link it up to a cell reference to visually show the full coordinates in the spreadsheet.
Adding Vertical Error Bars
So how do we turn a single dot on a Scatter Plot into a vertical bar with no dot? Now is time for the creative part!
What we will be adding to the plotted dot is an Error Bar. What is an Error Bar you might be thinking? It is used in statistics to indicate the margin of error for a given value. This allows someone to chart a value but show the audience that the value might be within a range of numbers that are either greater or less than that value.
We can use this margin indicator line to our advantage and setup up the spreadsheet to allow us to draw a vertical line right on the chart. To add an Error Bar you will need to follow the below steps.
-
Select the Scatter Plot series
-
Navigate to the Chart Design Ribbon tab
-
Open the Add Chart Element menu
-
Open the Error Bars menu
-
Select More Error Bars Options…
The Format Error Bars Pane should appear on the right-hand side of your Excel application window.
Open the Error Bar Options drop-down menu and ensure the Y Error Bars for your Series is selected.
Change the Direction = Plus and End Style = No Cap.
For the Error Amount, choose Custom and click the Specify Value button. This will open a dialog box where you will need to designate a Positive and Negative value for your Error margin. Since our plotline is already at zero, we only want our margin to be positive. For this reason, you can set the Negative value to 0.
The positive value will determine the length of your line. You will typically want this to be equal to or greater than the largest value in your bar/line chart.
For an even more dynamic solution, I recommend setting up a cell that reads the values from your chart and determines the maximum value. In this example, the cell used has the formula:
=MAX(B20:M20)
If you want to ensure your line ends a little bit higher than your max value, you can add a percentage increase to your formula. Typically adding 5% does the trick for me. This will change your formula to look something like this:
=MAX(B20:M20) * 105%
After you have set up your Custom Error Bar, you should see the line plotted on your chart.
Formatting The Vertical Line
Once your vertical line is created, the last step will be to format your line to your desired look. Here are the format settings I will typically use:
-
Line Weight: 1.5 pts
-
Dashes: Rounded Dots
-
Shape Outline Color: Medium/Light Grey
-
Marker Fill Color: None
-
Marker Border Color: None
After some further format changes to the chart itself, you can have a very professional-looking chart with a vertical line plot directly inside it.
Automating The Vertical Line’s Movement
You may choose to manually update the vertical lines’ X Value every time, but you may also be able to utilize a formula to handle the movement for you.
Let’s look at the article example. The vertical line represents the separation of Actual vs. Forecast Sales results.
Looking at the data table, we can incorporate a simple COUNTIFS function to count how many months are designated as “Actuals”. This way, as the year progresses, the vertical line in the chart will move along as more and more months become “Actuals”.
Depending on your situation, you may be able to come up with a similar sort of formula to automate your vertical line movement as time progresses.
Adding Text Labels Above Your Vertical Line
Now let’s say you want to add a label to your vertical line to give your audience clarity on what it is defining. We can tweak the setup of the vertical line to incorporate the use of a data label.
In order to position a data label at the top of the vertical line, we’ll need to move our plotted dot to the very top of the line.
To do this, you simply need to turn your Max Bound value negative and ensure your Y value has a formula equating to a positive version of your Max Bound value (just multiply by -1).
This will move your plotted dot up to the top and carry your line length down southbound (negative) to end at zero.
After you’ve re-jiggered your vertical line setup, you can then proceed to add a data label. Simply select your plotted dot and right-click on it. Then open the Add Data Labels menu and click Add Data Labels.
You should then see a data label appear next to your vertical line.
Next, you’ll likely want to reposition your data label to be directly over your vertical line. To do this, select and right-click on your data label. Click the Format Data Point menu option and the Format Data Label pane should open up.
In the Label Position section of the Label Options, select Above.
Finally, you’ll want to customize the text that is stored in the label. After selecting the Data Label, you can write a text formula (similar to the screenshot above) or you can link the Data Label to a spreadsheet cell with your desired text value.
The final result should look something like this:
Download Examples In Excel
If you would like to instantly download an Excel file I put together with exact chart examples used in this article along with a few other examples, feel free to click the below download button. No strings attached
I Hope This Helped!
Hopefully, I was able to explain how you can add a vertical line to your Excel Charts. If you have any questions about this technique or suggestions on how to improve it, please let me know in the comments section below.
About The Author
Hey there! I’m Chris and I run TheSpreadsheetGuru website in my spare time. By day, I’m actually a finance professional who relies on Microsoft Excel quite heavily in the corporate world. I love taking the things I learn in the “real world” and sharing them with everyone here on this site so that you too can become a spreadsheet guru at your company.
Through my years in the corporate world, I’ve been able to pick up on opportunities to make working with Excel better and have built a variety of Excel add-ins, from inserting tickmark symbols to automating copy/pasting from Excel to PowerPoint. If you’d like to keep up to date with the latest Excel news and directly get emailed the most meaningful Excel tips I’ve learned over the years, you can sign up for my free newsletters. I hope I was able to provide you some value today and hope to see you back here soon! — Chris
Usually, horizontal lines are added to a chart to highlight a target, threshold, limits, base, average, or benchmark. These lines, for example, can help control if a process is behaving differently than usual. Excel allows you to add a vertical line to an existing chart in several different ways, e.g., by calculating line values for a scatter, line, or column chart, but using error bars is the easiest way to add a vertical line to a chart:
See how to add a vertical line to the scatter plot, a line or bar chart, or a horizontal line to a chart.
To add a horizontal line to a line or column chart, do the following:
I. Add new data for the horizontal line
1. Add the cells with the goal or limit (limits) to your data.
For example, cell C16 contains the goal that should be displayed as a horizontal line:
II. Add a new data series
2. Add a new data series to your chart by doing one of the following:
- Right-click on the chart plot area and choose Select Data… in the popup menu:
- On the Chart Design tab, in the Data group, choose Select Data:
In the Select Data Source dialog box, under Legend Entries (Series), click the Add button, then in the Edit Series dialog box, type:
- Optionally, in the Series name box, the name of this line (for this example, Goal),
- In the Series values box, the cell with the goal (for this example, $C$16):
By default, Excel adds the new data series to the first point on the x-axis. Note that a new data series can be invisible (see how to select invisible chart elements):
III. Change a data series type
Note: This step is necessary because Excel adds only Y Error bars to the first and last data points. To see the horizontal line, you need to add X Error bars.
3. Right-click on any data series and choose Change Series Chart Type… in the popup menu:
In the Change Chart Type dialog box, choose the Scatter type:
Don’t worry about the chart! Repeat step 2 to change the data series:
- In the Select Data Source dialog box, select the added data series, then under Legend Entries (Series), click the Edit button.
- In the Edit Series dialog box, in the Series X values box, add any cell from the horizontal (category) axis but the first or last one (see the note why).
For example, $B$8:
You will see the correct data for the same horizontal (category) axis:
IV. Add the horizontal line
4. On the chart, select the new data series (see how to select invisible chart elements), then do one of the following:
- Click on the Chart Elements button, select the Error Bars list, then choose More Options…:
- On the Chart Design tab, in the Chart Layouts group, click the Add Chart Element dropdown list:
In the Add Chart Element dropdown list, choose the Error Bars list, then click More Error Bars Options…:
See more about other options in Adding Error bars.
5. On the Format Error Bars pane for the Horizontal Error bar (see below how to select the Horizontal Error bar), on the Error Bar Options tab:
- In the Direction group, select Both,
- In the End Style group, select No Cap,
- In the Error Amount group, select the Custom option, then click the Specify Value button:
On the Custom Error Bars dialog box, type or select the appropriate value for negative and positive values. For this example:
You can then make any other adjustments to get the expected look.
Note: To select the Horizontal Error bar for some data series, do one of the following:
- Click the arrow next to Error Bar Options and choose the Series {data series name}: X Error Bars in the dropdown list:
- On the Chart Format tab, in the Current Selection group, click the arrow of the Chart Elements dropdown list, then select Series {data series name}: X Error Bars for the needed data series:
See also this tip in French:
Comment ajouter une ligne horizontale au graphique.