Adding a horizontal line to an Excel chart

AID: 4452
  • Status: Published

2420 points

  • Bypdoelle
  • TypeTutorial
  • Posted on2011-02-02 at 13:47:27
Introduction
You may want to add a horizontal line in an Excel 2003 chart to indicate a constant, such as an average, median or threshold value.
horizontalline.jpg
  • 36 KB
  • This example illustrates how this technique can be used to display additional useful information in your charts.
This example illustrates how this technique can be used to display additional useful information in your charts.

Using Excel 2003, this can be accomplished using the “Error Bar” method as follows:
1) A single point is added to the chart at the correct height, and at one horizontal unit from the y axis.
2) A left-side error bar one unit wide is added to this new data point.
3) The horizontal scale for this series/point only is stretched to fit the width of the chart.
4) Various formatting is applied for consistent results.

Steps
The instructions below assume that you have already created a chart, and would like to add the horizontal line.

Adding a data point to the chart

Right-click chart and select Source Data from the menu that appears.

Click on Series tab, and click the Add button.

Enter the text that you want to appear in the Legend in the Name field. Excel will automatically add the “=” and quotes later.

Enter ={1} in the X Values field.

In the Y Values field, enter a reference to the value at which you want the horizontal line to appear.

Click OK.

Note: If either the X or Y Values field did not appear, you will have to right-click the data point you just added, select Chart Type, and change the type to XY (Scatter). You can then return to this Source Data screen to add the missing data.

horizontalline01.jpg
  • 75 KB
  • A data point added to the chart
A data point added to the chart


The new data point will appear on chart at the correct height for the horizontal line.

Right-click data point and select Format Data Series.

horizontalline02.jpg
  • 28 KB
  • The new data point in the chart
The new data point in the chart


Click on the Patterns tab.

Set the line and marker colour.  Change the marker style to a plus sign.

horizontalline03.jpg
  • 78 KB
  • The line and marker format is set
The line and marker format is set


Click on the Axis  tab.

Select Secondary axis.

Note: Excel incorrectly assumes that we will be creating a secondary Y axis. We will change this to an X axis later.

horizontalline04.jpg
  • 67 KB
  • Changing data series to secondary axis
Changing data series to secondary axis


Adding the Error Bar

Click the X Error Bars tab.

Select a Minus display type.

Enter a fixed error amount of 1.

horizontalline05.jpg
  • 70 KB
  • Adding the error bar
Adding the error bar


Click the Data Labels tab.

Select Y Value to display a number beside the horizontal line.

Click OK to close the dialog box.

horizontalline06.jpg
  • 50 KB
  • Set value to be displayed beside the bar
Set value to be displayed beside the bar


Formatting the secondary axis

Right-click on the chart and select Chart Options.

Click on the Axes tab.

Under Secondary axis, check Value (X) axis, and uncheck the Value (Y) axis checkboxes.

Click OK to close the dialog box.

horizontalline07.jpg
  • 74 KB
  • Formatting the secondary axis
Formatting the secondary axis


Now, we will hide the secondary axis without actually removing it.

Double click the secondary axis in the chart to open the Format Axis dialog box shown here.

Click on the Patterns tab.

Set the three tick mark options to None.

horizontalline08.jpg
  • 73 KB
  • Hide the secondary axis
Hide the secondary axis


Next, we will stretch the scale to the width of the chart.

Click on the Scale tab.

Set the Maximum value to 1. This will automatically uncheck the Auto box beside it.

Click the OK button to close the dialog box.

horizontalline09.jpg
  • 66 KB
  • Scaling the bar to stretch the width of the chart
Scaling the bar to stretch the width of the chart


The line is there. All that remains is to format it (optional.)

Double-click on the error bar.

Set the colour and marker as desired.

Click OK.

horizontalline10.jpg
  • 51 KB
  • Change the bar's colour and style
Change the bar's colour and style


Double-click the data label beside the horizontal line.

horizontalline11.jpg
  • 8 KB
  • The data label
The data label


Set the text’s colour, size and font.

Click OK.

horizontalline12.jpg
  • 96 KB
  • Format the label text
Format the label text


The result!

horizontalline13.jpg
  • 52 KB
  • The result
The result
    Asked On
    2011-02-02 at 13:47:27ID4452
    Tags

    error bar Excel 2003 chart line

    Topic

    Microsoft Excel Spreadsheet Software

    Views
    1830

    Comments

    Author Comment

    by: pdoelle on 2011-02-02 at 13:49:02ID: 23429

    I welcome any comments you may have on this article, or any suggestions that you may have for further articles in the same vein.

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Join Experts Exchange Today

    Gain Access to all our Tech Resources

    Get personalized answers

    Ask unlimited questions

    Access Proven Solutions

    Search 3.2 million solutions

    Read In-Depth How-To Guides

    1000+ articles, demos, & tips

    Watch Step by Step Tutorials

    Learn direct from top tech pros

    And Much More!

    Your complete tech resource

    See Plans and Pricing

    30-day free trial. Register in 60 seconds.

    Loading Advertisement...

    Top MS Excel Experts

    1. dlmille

      1,351,499

      Genius

      10,680 points yesterday

      Profile
      Rank: Genius
    2. ssaqibh

      542,555

      Sage

      0 points yesterday

      Profile
      Rank: Genius
    3. rorya

      381,757

      Wizard

      4,225 points yesterday

      Profile
      Rank: Savant
    4. imnorie

      334,112

      Wizard

      0 points yesterday

      Profile
      Rank: Genius
    5. teylyn

      282,850

      Guru

      20 points yesterday

      Profile
      Rank: Genius
    6. barryhoudini

      280,460

      Guru

      0 points yesterday

      Profile
      Rank: Genius
    7. redmondb

      235,511

      Guru

      2,000 points yesterday

      Profile
      Rank: Sage
    8. matthewspatrick

      230,947

      Guru

      2,010 points yesterday

      Profile
      Rank: Savant
    9. byundt

      197,840

      Guru

      820 points yesterday

      Profile
      Rank: Savant
    10. zorvek

      144,626

      Master

      0 points yesterday

      Profile
      Rank: Savant
    11. StephenJR

      136,537

      Master

      0 points yesterday

      Profile
      Rank: Genius
    12. nutsch

      117,005

      Master

      0 points yesterday

      Profile
      Rank: Genius
    13. gowflow

      110,036

      Master

      0 points yesterday

      Profile
      Rank: Sage
    14. MartinLiss

      107,333

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    15. GlennLRay

      95,652

      Master

      0 points yesterday

      Profile
      Rank: Guru
    16. robhenson

      90,250

      Master

      0 points yesterday

      Profile
      Rank: Sage
    17. ScriptAddict

      88,470

      Master

      0 points yesterday

      Profile
      Rank: Guru
    18. kgerb

      85,022

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    19. aikimark

      84,456

      Master

      3,310 points yesterday

      Profile
      Rank: Genius
    20. andrewssd3

      80,242

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    21. Wiesje

      69,918

      Master

      0 points yesterday

      Profile
      Rank: Master
    22. Shanan212

      66,418

      Master

      0 points yesterday

      Profile
      Rank: Master
    23. krishnakrkc

      59,548

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    24. Michael74

      54,744

      Master

      0 points yesterday

      Profile
      Rank: Wizard
    25. regmigrant

      51,070

      Master

      0 points yesterday

      Profile
      Rank: Guru

    Hall Of Fame