PTS Blog

Main menu:

PTS Utilities

Commercial Utilities developed by Peltier Technical Services

Waterfall Chart
Box and Whiskers


 

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

Subscribe

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

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

Clustered-Stacked-Column Combo Chart With Lines

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

Excel offers clustered column charts and stacked column charts among its standard options.

Clustered Column ChartStacked Column Chart

A common request is for a clustered-stacked column chart where the columns are clustered together, while one or more of the clustered columns are divided into sections stacked on top of each other. This isn’t built into Excel, but by rearranging the worksheet data, it can be constructed readily.

In Clustered-Stacked Column Charts I showed how to construct such a chart.

Clustered Column Chart

But now I’ve been asked to extend the combination to include a set of lines on the secondary vertical axis.

Clustered Column Chart

Suppose we have the simple data below, with four series of data over three months. One series is to be by itself in the left column of the cluster, and three series stacked on the right.

Clustered Column Chart Data

Following the rationale in Clustered-Stacked Column Charts, the data must be rearranged to the following format, so all of the columns will be positioned as desired.

Clustered Column Chart Data

Select this range and create a stacked column chart. It’s halfway done, we just need some formatting.

Clustered Column Chart

Change the gap width of any series to zero, and it looks almost done.

Clustered Column Chart

In Clustered-Stacked Column Charts, we used a dummy series to make the category axis labels look right. To add a set of lines which are cenetered on each cluster of columns, we will use the same approach. Here is the data for the line series. This simple data works; note its arrangement parallels the original data.

Clustered Column Chart Data

Here is what the chart’s axis should look like when we’re done:

Clustered Column Chart

Copy the data in F1:I3, select the chart, and use Paste Special to add the data as a new series, with data in rows, category labels in the first row (we’ll have to reapply this later), and series names in the first column. The data is stacked on top of the first three categories.

Clustered Column Chart

What we need to do is put the line series on the primary axis and the stacked column series onto the secondary axis (if we reverse this, we will have problems displaying the Jan-Feb-Mar axis labels). Select one of the series, and move it to the secondary axis. I usually move the lowest valued series first (B3 in this example) so that the secondary axis series don’t obscure the primary series I need to select and move next.

Clustered Column Chart

In turn, select and move all of the A and B column series to the secondary axis. The A and B series are clustered, not stacked, because that’s Excel’s default column chart variation.

Clustered Column Chart

Select one of the secondary axis series, and change its chart type to stacked. All column series on that axiss will follow suit. Also, change the gap width of a secondary axis column to zero.

Clustered Column Chart

Excel has given us a secondary value (Y) axis, but we only have the primary category (X) axis. Using Chart menu > Chart Options > Axes tab, or in Excel 2007, the Chart Tools > Layout tab, to add the secondary axis to the chart. At first, we don’t have the month names as our labels, because Excel applied the existing labels (B through K) to all series.

Clustered Column Chart

Edit the series source data or the series formula for the Axis series, so that the months in G1:I1 are used for category labels.

Clustered Column Chart

The stacked column Y axis (secondary) is along the right edge of the chart, and the line Y axis (primary) is along the left. We want to switch these axes. Format the secondary X axis (top) so that the Value Y Axis does not cross at the maximum category (uncheck the box). Then format the primary X axis (bottom) so that the Value Y Axis does cross at the maximum category (check the box).

Clustered Column Chart

Almost done. The month names are not centered correctly under the clustered columns. Format the scale of the secondary category axis (B through K at the top of the chart) so that the value axis does not cross between categories.

Clustered Column Chart

Perfectly aligned. Now convert one of the line series from a column to to a line style.

Clustered Column Chart

Repeat for the other line series.

Clustered Column Chart

Now format the secondary category axis (B to K along the top of the chart) to display no tick labels and no tick marks. Adjust the plot area width so the legend does not obscure the Y axis labels.

Clustered Column Chart

You may want to reposition the legend.

Clustered Column Chart

This chart illustrates a problem with secondary axes, which Stephen Few wrote about in Dual-Scaled Axes in Graphs-Are They Ever the Best Solution?, and which I followed up in Secondary Axes in Charts. The problem is twofold. First, having the primary and secondary series overlapping in the same chart space makes it unclear which series corresponds to which axes. Second, it is impossible to separate the primary and secondary series visually. For example, although the lines and columns are independent, the red line seems to match with the green column at the endpoints but with the blue column in the middle.

These problems can be avoided by using two separate charts, or if you’re a bit more adventurous, by creating a panel chart.

Panel Chart

Panel Chart

Arranging the chart that way without changing its height shortens the vertical scales, reducing resolution of the axes. The legend can be moved and the chart made taller and narrower.

Panel Chart

This illustrates a problem with chart legends. First, they force the reader to move his eyes between the charted data and the legend. Second, in this case, the legend is completely out of order compared to the plotted points. It is usually better to use data labels right in the chart.

Panel Chart

Possibly Related Posts:

Bookmark and share this entry:
  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • TwitThis
  • StumbleUpon
  • Google
  • Reddit
  • MySpace

Comments

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.

Read the PTS Blog Comment Policy.


Comment from Bob
Time: Friday, August 8, 2008, 8:50 am

Jon,

I visit this site everyday. I am always amazed at what can be done with Excel charts.
Great tutorial.

Bob


Comment from Rick Williams
Time: Monday, August 11, 2008, 7:23 pm

I notice how you often place the series labels on the last data point of your series. I like the idea, and it always makes sense on the examples you describe, but usually when I try to do the same thing the effect isn’t the same; often the chart has too many datapoints or the endpoints are too close together. Do you have any guidelines on how you might best incorporate dataseries labels into a chart?


Comment from Jon Peltier
Time: Monday, August 11, 2008, 8:38 pm

Hi Rick -

Sounds like a topic for another entry. I haven’t codified my approach, there’s still a bit of art in it. I like to make the label text the same color as the markers or lines in a line or XY chart. I look for places in the chart where there is good separation between series, so labels are not cluttered and there is less chance for confusing which label goes with which points. Labeling the rightmost point in a series means usually there is room for the label to the right of the point.

I have a simple macro which automatically labels the last point of all series in a chart with the series name. I no longer use it myself, because it applies static text, and the label doesn’t change if I update the series name. It’s a simple fix which I may make someday (another blog topic!). Anyway, the simple macro can be found here:
Label Last Point


Comment from Jason
Time: Thursday, August 28, 2008, 10:16 am

Jon-

Thanks for this trick! Very cool! I used it today!! Great site!

-Jason


Comment from Amy
Time: Tuesday, September 23, 2008, 11:07 am

Hi!

I’ve been struggling through this and finally noticed one instruction that I seem to have been missing:

“The stacked column Y axis (secondary) is along the right edge of the chart, and the line Y axis (primary) is along the left. We want to switch these axes.”

My question is how do you do this? Am I going through and switching series’ axis from secondary to primary and vice versa?

I may be dense or just missing the obvious but would greatly appreciate the help.

Thanks,
Amy


Comment from Jon Peltier
Time: Thursday, September 25, 2008, 12:18 am

Amy -

The rest of the paragraph explains how to do this:

“Format the secondary X axis (top) so that the Value Y Axis does not cross at the maximum category (uncheck the box). Then format the primary X axis (bottom) so that the Value Y Axis does cross at the maximum category (check the box).”

To format the scale of an axis, select the axis, press CTRL+1 (numeral one) to open the dialog, and on the Scale tab (Excel 2003 & earlier) or on the first tab of Excel 2007 (I forget its name), check or uncheck the appropriate box.


Comment from Amy
Time: Thursday, September 25, 2008, 2:44 pm

Thanks Jon. For some reason, my axes weren’t flipping when I did that. They are now!! Go figure.

Thanks again,
Amy


Comment from Bridget
Time: Tuesday, November 25, 2008, 12:50 pm

Hi John,

Thanks for the post. I followed the Clustered-Stack Column Chart page, and generated a nice chart. However, now I want to add 6 more data series (which will all be lines, and on a different scale than the current axis for the bars). This applies to your above example, but with the following exception - the data series which I hope to add as lines to the bar chart does not parallel the bar chart data series. More specifically, the x-values for the bar chart are months (Jan, Feb, March, etc.), but the x-values for the line chart are daily (Jan 1, 2008; Jan 2, 2008; Jan 3, 2008; etc.). Is there a way to generate the chart, nevertheless, or do the x-values have to match? I know I could average the data for the month to make the data parallel with the bar chart, but I would rather have the daily variation visible in the line data series.

Thanks.

- Bridget


Comment from Jon Peltier
Time: Tuesday, November 25, 2008, 2:09 pm

Hi Bridget -

Most things are possible in Excel, you just need to know which preconceptions need to be broken.

However, there are a couple of issues with what you want to do:

First, the column clusters are positioned monthly with an equal space for each month. Plotting daily data on top of this results in an unequal space for each month because of the different numbers of days in each month.

Second, in general showing items on primary and secondary axes can lead to confusion, and showing the monthly columns and daily values on the same chart are likely to increase that confusion.

Because of these two issues, I’d think using two charts would be prudent.


Comment from Ben
Time: Tuesday, December 2, 2008, 4:57 pm

Hi Jon, I’ve followed all the necessary directions for creating a chart with stacked columns and lines. However, when I change the chart type to lines, they do not show. They will display the markers but no lines. Any idea why this might happen? I’m using Excel 2007.

Thanks,
Ben


Comment from Jon Peltier
Time: Tuesday, December 2, 2008, 5:36 pm

Ben -

Is the data for the lines contiguous as in my example of F1:I3, or sparse ike the column data in A7:whatever? If it is sparse, I suspect the problem is the setting for how Excel plots empty cells. By default, Excel doesn’t plot anything for a blank cell, so you’re seeing the gaps between populated cells. Select the chart, then go to Tools menu > Options > Charts and change the setting to Interpolate. Sometimes in a combination chart, you cannot set this property. Insetad you need to enter #N/A into the cells where you want the line to interpolate over.


Comment from Ben
Time: Tuesday, December 2, 2008, 7:08 pm

Jon, thank you for your very quick help. I couldn’t find the option to Interpolate. Fortunately by filling the empty cells with #N/A the lines filled in just as I was hoping. Thanks again for the solution and for developing this site.

Ben

Write a comment





Subscribe without commenting

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