Peltier Tech Blog

Excel Charting Utilities | Custom Solutions | Training | Charts and Tutorials | PTS Blog

 

Main menu:

 
Peltier Tech
Chart Utilities

PTS Waterfall Chart Utility
PTS Cluster-Stack Column Chart Utility
PTS Box and Whisker Chart Utility
PTS Marimekko Chart Utility
PTS Dot Plot Utility
PTS Cascade Chart Utility

Subscribe

Site search

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Buy me a coffee

If this topic or the whole blog has been helpful, support further development by treating me to a cup of coffee.


Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Chart with a Dual Category Axis

by Jon Peltier
Tuesday, April 22nd, 2008
Peltier Technical Services, Inc., Copyright © 2010.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Through appropriate arrangement of your source data, you can give your chart a dual category axis. This approach works with chart types that have an “Category” type category (X) axis, that is. line charts, column charts, and bar charts. The chart below shows defect rates in several different components, which are grouped into a smaller number of categories.

Column Chart with Dual Category Axis

The data arrangement is shown in the following table:

 

A B C D E
1 Mechanical Electrical Hydraulic
2 Mechanical Gear 11
3 Bearing 8
4 Motor 3
5 Electrical Switch 19
6 Plug 12
7 Cord 11
8 Fuse 3
9 Bulb 2
10 Hydraulic Pump 4
11 Leak 3
12 Seals 1

 

There are three categories: Mechanical, Electrical, and Hydraulic. These categories are listed in the first column, and also in the first row. The second column shows the sub-categories, for example, Gear, Bearing, and Motor under Mechanical. The cells filled with yellow should be completely blank. The first two cells in the top row are blank to instruct Excel to use the first row as series names and the first two columns as category labels. The blank cells under each main category in the first column tells Excel that each main category applies to several subcategories. I used separate columns for the three categories so that each is plotted in its own series, making it easier to format each major category separately.

 

To make the chart, select this entire data range and insert a stacked column, stacked bar, or unstacked line chart. (Note: you could use clustered column or bar charts, but then you would have to format each to use an overlap of 100% between series.)

Line Chart with Dual Category Axis

The column chart type is probably the best selection (see top of page), as long as there are not too many categories and subcategories. The line chart (above) gives more emphasis to an illusory relationship between points by connecting them with lines. The bar chart (below) works almost as well as the column chart, but Excel provides no way to orient the major categories horizontally.

Bar Chart with Dual Category Axis

First in a series

Related Posts:

Bookmark and share this entry:
  • Twitter
  • Digg
  • Facebook
  • LinkedIn
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • MySpace
  • Slashdot
  • Yahoo! Buzz
  • Tumblr

Learn how to create Excel dashboards.

Comments


Comment from Tony
Time: Tuesday, April 22, 2008, 4:16 pm

I agree that the top chart is the best layout for this data. The line chart leads me to think that time is on the x-axis or there is a relationship between the series, which is not accurate. Also, nice use of color!

One point; the y-axis scale is different in the bar chart (5) versus column chart (2). I am leaning towards the preference of the y-axis scale being two.

Would you suggest a pareto chart for this data?

Nice tip!


Comment from Jon Peltier
Time: Tuesday, April 22, 2008, 5:11 pm

Tony – I included the line and horizontal bar versions of the chart almost as an afterthought, so I didn’t notice the change in the Y axis scale of the bar chart. I agree that it looks better, more precise maybe, using an axis tick spacing of 2, so I made the change and uploaded the new chart.

If you notice, this is almost a pareto chart, at least within each category the data is sorted from high to low. You could set up an Excel pivot table (I feel my next post coming on) that would sort both outer and inner categories by number of occurrences.


Comment from Robert Martim
Time: Saturday, May 10, 2008, 1:20 pm

Hi Jon,

“Funtastic” chart! It is a pitty I am color-blind and cannot appreciate the “nice use of color” that Tony mentions above. Nevertheless, the result is very clean and very easy to read.

The column chart gives a perfect picture of the data in a clea, clean and concise way!

Thanks for sharing this!

Rob


Comment from Mick Coleman
Time: Friday, June 12, 2009, 6:45 am

Jon,

is there any way of separately formating the x-axis ?
E.g. different font colours for Mechanical or Engineering (especially if you wanted to minimise the number of formating lines in the graph) ?


Comment from Jon Peltier
Time: Friday, June 12, 2009, 6:59 am

Excel doesn’t allow for individually formatted axis tick labels. You can fake it using dummy series, as shown in Individually Formatted Category Axis Labels. For a dual set of labels it requires two dummy series and some cleverly laid out text labels.


Comment from Shirlene
Time: Friday, June 12, 2009, 11:10 am

I have been fighting a problem with this category layout in Excel 2007. Jon, I know you are not happy with 2007 but I wonder if you know of a work-around. When doing the multi-level, or dual, category X-axis, it works great in XL2003. It also works great in XL2007…up to 100 rows of data. As soon as the 101st row of data is added, the group category (your Electrical, Mechanical, Hydraulic above) removes every other group.

Do you have any ideas on how to fix this?

Thanks,
Shirlene


Comment from Jon Peltier
Time: Friday, June 12, 2009, 3:18 pm

Shirlene -

This is what they call a “known issue” in Excel 2007. I have not tried to find a workaround for this, since in general more than 100 categories make an axis unreadable. I think the 100 category limit plays havoc with single lavel axis labels too.


Comment from Shirlene
Time: Tuesday, June 16, 2009, 5:56 am

Thanks for the reply. That’s what I suspected but thought that you might have found a work-around for it. I’ve tried and haven’t been successful. My user’s chart contains all 50 states as the outside level and 5 categories per state on the second level. This chart is not printed and this is what her boss wants so she is stuck doing it this way.

If you do find or hear of a work-around, please let me know. I’d really appreciate it and so would my user.

Thanks,
Shirlene


Comment from Jon Peltier
Time: Tuesday, June 16, 2009, 8:36 am

So there are 250 categories? I can’t think of a good way to do that!


Comment from Shirlene
Time: Tuesday, June 16, 2009, 9:40 am

I agree but this is what the user wants. And, sadly enough, it worked fine in XL2003.

Thanks for your help, anyway, Jon. I appreciate your comments.

Shirlene


Comment from Jon Peltier
Time: Tuesday, June 16, 2009, 3:55 pm

Shirlene -

It just occurred to me that Excel 2007 has a problem if there are more than (I think) 99 category labels. Above this number, you no longer have any control over how the labels are displayed.

You might try to use a alternate approach, Individually Formatted Dual Category Labels, which uses data label on invisible series instead of the built-in axis labels. Excel will put all of the labels wherever they go, no matter whether they overlap. So it will get around Excel 2007’s problems with too many category labels.


Comment from Simon
Time: Thursday, September 24, 2009, 10:28 am

Hi Jon,
Thanks again for your blog, I keep coming back to it to learn how to do stuff I want to do, or just to get new idea.

Before my main question, here’s a suggestion : Would it be possible to make a “printer friendly ersion” of the page? I like to print some of your pages because I dont have internet on my work computer and I dont need the menus on the left and other stuff.. Thanks :)

Main question:
I am trying to make a dual-axis very similar to yours, but I want to display two numbers for each category. For example, Mechanical-Bearing would have ‘failure rate last year’ and ‘failure rate today’. The problem I have is if I want to display the legend, it shows these 2 variables as many times as I have categories.

Example:
http://ceh.servehttp.com/upload/Classeur1.xls

(Here, I would like all the ‘failure rate this year’ to be a color, the ‘failure rate last year’ to be another and to have only 2 options in the legend, not 2*3..

any idea?
Thanks
Simon


Comment from Jon Peltier
Time: Thursday, September 24, 2009, 11:26 am

Hi Simon -

If you don’t want different formatting for the different main categories (Mechanical etc.), then move the ‘this year’ data from columns E and G into column C, and the ‘last year’ data from F and H into D, and only use columns C and D for your Y values.

Also thanks for the printer friendly suggestion. I have certainly considered this option, but haven’t gotten around to figuring out how to implement it. One of these days.


Comment from Stuart West
Time: Thursday, October 8, 2009, 10:51 am

Hi Jon,

I’m having a problem with a chart like the one at the top of the page. For chart formatting reasons, the top and bottom cells in each subcategory group have been left empty (so in your example, B2 would be empty, Gear, Bearing and Motor would be in B3 to B5, B6 would be empty and so on). This works great except for the last empty cell in the table, which Excel treats as a new category instead of a subcategory. Can you suggest any way around this?


Comment from Jon Peltier
Time: Thursday, October 8, 2009, 12:35 pm

Stuart -

Where is the last empty cell in my table (corresponding to yours)? Do you mean A12? Make sure the cell is really empty, and doesn’t contain for example a stray space character.


Comment from Stuart West
Time: Friday, October 9, 2009, 4:39 am

Hi Jon,

Thanks for the response. It’s probably easiest if I show an example:

http://farm4.static.flickr.com/3440/3994464489_5698777cc9_o.jpg

The last row of the table contains only blank cells, but always shows up on the chart as a new category.


Comment from Jon Peltier
Time: Friday, October 9, 2009, 7:18 am

Stuart -

I see. In both Excel 2003 SP3 and 2007 SP2, if row 31 is completely blank, or if cell B31 contains a space character, the last item is a subcategory. If A31 contains a space character or a formula that returns “”, Excel recognizes it as a non blank cell in column A and gives it its own category. Select cell A31 and press Delete, and it should fix the axis labels.


Comment from Stuart West
Time: Friday, October 9, 2009, 7:50 am

Thanks! Somehow pressing delete wasn’t helping, but putting a space character in B31 sorted out the problem. That had completely stumped everyone in the office, so thanks again.


Comment from Tyler
Time: Tuesday, January 12, 2010, 4:02 pm

Hi Jon,

Thanks for this great site, it’s very helpful!

My question is this: I use multi-category charts in Excel 2007 on a regular basis. In many of mine, I have a large number of categories and each has only two sub-categories. In some cases the category names are long and the sub-categories are not, and I run into an issue where the category names do not wrap, resulting in overlapping letters with the next category. What puzzles me is that some of my charts DO wrap properly. I can’t find any setting for this. Do you know how I can cause my category names to wrap?

Thanks in advance,
-Tyler


Comment from Tyler
Time: Tuesday, January 12, 2010, 5:02 pm

Jon,

After more tinkering, I found that Excel wraps the categories if it has fewer than 14 of them in a single chart. If I add a 14th or beyond, the categories stop wrapping. Not sure if this is by design or a bug, but in any case I decided the simplest solution is to create a second chart and divide the categories across the two. This works for my purposes. Still a puzzling case though.

-Tyler

Write a comment

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.

Read the PTS Blog Comment Policy.





Subscribe without commenting

PTS Waterfall Chart Utility PTS Cluster-Stack Column Chart Utility PTS Box and Whisker Chart Utility PTS Marimekko Chart Utility PTS Dot Plot Utility PTS Cascade Chart Utility

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