Peltier Technical Services, Inc.
 

Peltier Technical Services, Inc.
- Custom Excel Solutions

PTS Blog: Charts and Things

Jon's Excel and Charting Pages
- Jon's Charts - Tutorials - Excel
- Site Index and Search - RSS


PTS Utilities

Commercial Utilities developed by Peltier Technical Services

  Waterfall Chart
  Box and Whisker
 

Excel Books

Books that I own and use while developing in Excel

Goods and Services

Excel or charting related products and services which I use or feel are worthwhile additions

 

Broken Y Axis.

A frequently asked question is "How do I break an axis so that one or two very large values don't drown out the rest of my chart?" Two common responses are:

  • Use a logarithmic scale.
     
  • Plot the large value(s) on a secondary axis.
     

But these aren't always satisfactory: some readers won't understand the log scale, while the secondary axis disconnects the large value from the others and requires more work for the reader to figure out. Also creating a column chart with a secondary axis is a lot of extra work to make the series line up. Here is an alternative approach which displays an actual break in the axis and in any columns that extend above the break.

In my original data, shown below, the two values highlighted in red are much greater than the rest of the numbers. The column chart below the table shows how these values overwhelm the rest of the points.

  A B C D
1 Original Data    
2   May June July
3 London 1,234,565 1,452,369 1,478,852
4 Paris 2,363,645 24,568,876 5,562,413
5 Madrid 23,645,254 3,211,654 5,857,421
6 Brussels 5,914,753 5,544,221 3,620,015
7 Lisbon 5,824,676 4,541,258 4,015,876
8 Munich 2,501,478 6,325,698 4,569,872

I've set up another table below the first in the worksheet. I put the following formula into cell B13, copied the cell, and pasted it into the entire range B13:D18.

    =IF(B3>8000000,B3-13000000,B3)

I will put my break at 8,000,000 and continue my axis above the break as if the break is at 21,000,000. The difference in values at the break results in the 13,000,000 subtracted from values greater than 8,000,000 in the formula.

  A B C D
11 Adjusted Data to account for gap
12   May June July
13 London 1,234,565 1,452,369 1,478,852
14 Paris 2,363,645 11,568,876 5,562,413
15 Madrid 10,645,254 3,211,654 5,857,421
16 Brussels 5,914,753 5,544,221 3,620,015
17 Lisbon 5,824,676 4,541,258 4,015,876
18 Munich 2,501,478 6,325,698 4,569,872

Here is how the adjusted data in A12:D18 looks in a clustered column chart. There is a definite separation between the outlying points and the rest of the data, but the smaller numbers are not obscured as above.

I set up a range for the custom Y axis in F1:H13 of the worksheet. The X values in column F are all zero, the desired axis tick labels are in column H, and in cell G2 I put this formula to compute the Y values for the axis ticks. Note its similarity to the formula in cell B13.

    =IF(H2>8000000,H2-13000000,H2)
  F G H
1   Markers Labels
2 0 0 0
3 0 1,000,000 1,000,000
4 0 2,000,000 2,000,000
5 0 3,000,000 3,000,000
6 0 4,000,000 4,000,000
7 0 5,000,000 5,000,000
8 0 6,000,000 6,000,000
9 0 7,000,000 7,000,000
10 0 9,000,000 22,000,000
11 0 10,000,000 23,000,000
12 0 11,000,000 24,000,000
13 0 12,000,000 25,000,000

I copied range F1:G13, selected the chart, and used Paste Special from the Edit menu. I used the Paste as New Series, Values in Column, Series Names in First Row, and Categories in First Column options. I got another column series, which I'll change in a minute.

I right-clicked on the new series, picked Chart Type from the popup menu, and picked XY Scatter, Markers Without Lines. The series now appears as red X's on the vertical axis, and Excel has added secondary X and Y axes for me.

I don't need the secondary Y axis, so I right clicked on the chart, selected Chart Options from the popup menu, clicked on the Axes tab, and unchecked the Secondary Y Axis checkbox. I also want to freeze the scale of the secondary X axis (top of the chart), so I double clicked it, clicked on the Scale tab, and unchecked the Auto box next to Minimum and Maximum, locking these parameters at 0 and 1, respectively.

To make the secondary X axis disappear, I double clicked it again, and on the Patterns tab, I selected None for Line, Major Ticks, Minor Ticks, and Labels. I double clicked the Y axis, and selected None for Major Ticks, Minor Ticks, and Labels, so just the line remained.

Double click on the Markers series, click on the Patterns tab, and change the markers to a black cross, size 6. Using Rob Bovey's Chart Labeler (a free addin from http://appspro.com), I added the labels in H2:H13 to the Markers series along the Y axis. I selected the Left position option; they didn't come out quite right, but 'll fix that in a minute.

To make room for the new axis labels, I had to select the plot area, and resize the top of it downwards and the left edge of it to the right.

Now it's time to add the breaks in the axis and in the columns. I will do that by adding a series with points where we want to show breaks, and then using a shape as a custom marker for this break (see Custom Chart Series Markers). I set up the following table in J1:O4.

  J K L M N O
1     series point   Cut Off
2 Gap Width 150 0 0 0 8,000,000
3 Num Series 3 2 2 0.25 8,000,000
4 Num Points 6 1 3 0.37963 8,000,000

The colored regions in this table are explained below:

The items in orange are required inputs in calculating the horizontal position of the "break" markers.
     Gap Width: this is the width between adjacent clusters of columns, in the percentage of a single column's width.
         The default is 150%, so the gap is as wide as 1-1/2 columns.
     Num Series: this is the number of series in the chart (3, for May, June, and July).
     Num Points: this is the number of points in each series (6, for the number of cities).
The items in yellow show which points require "break" markers.
These have been determined by inspection and entered manually, but could be automated with formulas.
     {0, 0}: This denotes the Y axis.
     {2, 2}: This is the second point in the second series (Paris in June).
     {1, 3}: This is the third point in the first series (Madrid in May).
The items in green are the horizontal positions of the "break markers", calculated using
     =IF(L2=0,0,(M2-1+($K$2/200+L2-0.5)/($K$2/100+$K$3))/$K$4)
Who's afraid of a little algebra?
The items in blue are the vertical positions of the "break markers" (8,000,000 as selected earlier)

I copied N1:O4, selected the chart, and used Paste Special from the Edit menu to add this data as a New Series, again using By Columns, Series Names in First Row, and Categories in First Column. The points are plotted here as red diamonds. If necessary, you may have to change this series into an XY Scatter series with markers and no lines, and you may have to rehide the secondary X axis.

Draw a Parallelogram Autoshape. The fill color of the shape should match the plot area fill color (white in this chart). It is shown here with a red border, although the real shape has no border. Use the Alt key to align it with the cell boundaries.

Draw two lines, using Alt key to align them with the sloped sides of the parallelogram.

Use white fill and no lines for the parallelogram. Select the parallelogram and both lines, and group them, using the Group command from the Draw submenu of the Drawing command bar.

Rotate the grouped shape once left or right and flip it once horizontally or vertically, using the appropriate commands on the Drawing > Draw > Rotate or Flip menu.

Finally, shrink it down to a convenient size. After shrinking it, you may have to ungroup the individual pieces and move each slightly. Don't try using the mouse to move them. Select one and use the arrow keys.

Use this shape as a custom data label for the Cut Off series. Copy the shape, select the Cut Off series in the chart, and Paste.

Select the legend, click on the Markers series text, and press the Delete key. Repeat with the Cut Off series legend text. Don't select the marker in the legend before pressing Delete, or you'll delete the series, not the legend entry.

That's it, a chart with a broken Y axis.

You can get a slightly different look if you use no markers for the Markers series, along the Y axis, set the major spacing of the Y axis to 1,000,000, and use the Outside Major Tick Mark.

If you're a bit more artistic, you can make a shape more like a tilde than a slash:

     

Click here for a zipped worksheet that runs through this procedure.

Other techniques for depicting breaks in an axis have been posted by Tushar Mehta and by Andy Pope.

 

 

Create Excel dashboards quickly with Plug-N-Play reports.


Peltier Technical Services, Inc.
We can customize or automate any example from this site, or build a new one for you. To discuss your project or obtain a quote, please contact me at jonxlmvp@peltiertech.com

PTS Blog: Charts and Things

Jon's Excel and Charting Pages
- Jon's Charts - Tutorials - Excel - Site Index and Search - RSS

Peltier Technical Services, Inc., Copyright © 2008. All rights reserved.
You may link to this article or portions of it on your site, but copying is prohibited without permission of Peltier Technical Services.

Microsoft Most Valuable Professional

Microsoft Most Valuable Professional

My MVP Profile