Category Labels That Don’t Overlap the Data
by Jon Peltier
Thursday, April 30th, 2009
Peltier Technical Services, Inc., Copyright © 2010.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
In Data Sets, Dick described his affection for data to his Daily Dose of Excel readers. One of his bar charts showed the life expectancy differential between men and women in various countries. In Bangladesh, men actually outlive women, so the bar extends into negative chart space, and the category label “Bangladesh” overlies this data.

Dick wondered how to avoid this problem. There are two ways, one very simple and the other slightly simple but more attractive.
I’ll illustrate with the following data. The “opposite” data in column C is dummy data for a hidden series which will provide data labels that replace the default axis labels. The values are defined by a simple formula: =-B2/ABS(B2). I could have used =-SIGN(B2), but I thought of this variation after I built the data range.

I created a bar chart using the first two columns of data.

Since Excel plots data starting from the axis and moving away, the first category (alpha) is plotted next to the axis, below the next category. It’s actually very logical, but people don’t understand this. Anyway, fix this by formatting the category axis so it is plotted in reverse order, and the value axis crosses at the maximum category, which isĀ at the bottom of the chart when categories are plotted in reverse order.

Okay, looks fine, except for the label “gamma” which overlap its data point.
I promised an easy way, so here goes. Format the category axis so the axis tick labels are in the “Low” position. They are plotted at the low side of the chart. This is a good quick way to move the labels out of the way, but in some cases, the labels may be moved pretty far from the axis. Because the labels need a margin, the entire chart is compressed laterally, reducing the resolution of the value axis scale.

So here is the almost as simple method, which eliminates the issues raised above. Extend the chart source data to include the “opposite” column of data.

Format either of the bar chart series so the overlap is 100%. Now the bars line up perfectly.

Format the category axis to remove the tick labels (select the “None”) position.

Add data labels to the “opposite” series, using the Category Labels option.

Format the data labels so they are in the “Inside Base” position.

Now hide the “opposite” series by formatting it to show no border and no area fill. Also remove the “opposite” legend entry by single clicking twice on its text label, and pressing Delete. (You could remove the legend altogether, since there’s but a single series.

The technique works just as well with column charts.

You could also use the Invert Excel Chart Format if Negative technique to further highlight the negative value.

Related Posts:
- Individually Formatted Category Axis Labels
- Area Chart – Invert if Negative
- Add a Target Line
- Individually Formatted Dual Category Labels
- Draw an Axis With Tick Marks But No Line
- Growth Rates in a Panel Chart
- Fill Between XY Chart Series (XY-Area Combo Chart)
- Legends in Excel Charts – Formats, Size, Shape, and Position
- Magazine Quality Chart (Economist)
- Fill Below an XY Chart Series (XY-Area Combo Chart)
Posted: Thursday, April 30th, 2009 under Chart Axes.
Comments: 3
Comments
Comment from chip
Time: Thursday, April 30, 2009, 8:42 pm
I like it. I agree that “Low” often puts the labels pretty far away.
Generally, Excel makes it really hard to make attractive charts unless they are very simple charts with short labels. The forced reorientation and skipping of labels and ignoring of settings to angle (or not) the text really annoys me. If I have a complex chart I often forego the x axis labels altogether, and format the columns underneath the chart to match the width of the bars and gaps. The I put the labels underneath and format them how I want–wrapped, vertically, etc.
Should I have to do that? I think not. The version of Harvard Graphics I used on a PC-XT running DOS 2 provide more control over the appearance and positioning of the axis labels. Or maybe I am only waxing nostalgic, but I remember the switch to the PPT graphing lo those many years ago, and looking for the ability to fix the labels.
Comment from Primo
Time: Friday, May 1, 2009, 2:50 am
I loved Harvard Graphics – I used a DOS version for years after I switched to Windows, I couldn’t understand why anyone would use Excel for drawing graphs. The Microsoft Graph program that Excel used was very basic and produced the ugliest graphs I’ve ever seen. And there was an add-on that extended the graph types to (as I remember) way beyond what Excel does now.
Pingback from ggplot2: Positioning Of Barplot Category Labels « Learning R
Time: Monday, June 1, 2009, 7:46 am
[...] 2009 June 1 tags: barplot, business, chart, excel, ggplot2, plot, R by learnr Jon Peltier demonstrates two ways of labeling a bar chart when some values are positive and others [...]



















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.