Peltier Tech Blog

Excel Chart Add-Ins | Training | Charts and Tutorials | Peltier Tech Blog

 

Main menu:

Peltier Tech Chart Utilities for Excel Peltier Tech Panel Chart Utility Peltier Tech Waterfall Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

 
Excel Dashboards
 

 
Amazon Books
 

Subscribe

Site search

Subscribe

Site search


Recent Posts

Popular Posts

Categories


 

Privacy Policy

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

Category Labels That Don’t Overlap the Data

 
by Jon Peltier
Thursday, April 30th, 2009
Peltier Technical Services, Inc., Copyright © 2012.
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.

Axis Label Overlapping Plotted 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.

Non-Overlapping Axis Label Data

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

Non-Overlapping Axis Label Bar Chart 1

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.

Non-Overlapping Axis Label Bar Chart 2

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.

Non-Overlapping Axis Label Bar Chart 2a - The Easy Way

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.

Non-Overlapping Axis Label Bar Chart 3

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

Non-Overlapping Axis Label Bar Chart 4

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

Non-Overlapping Axis Label Bar Chart 5

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

Non-Overlapping Axis Label Bar Chart 6

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

Non-Overlapping Axis Label Bar Chart 7

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.

Non-Overlapping Axis Label Bar Chart 8 - Ta-Daa!

The technique works just as well with column charts.

Non-Overlapping Axis Label Column Chart 0

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

Non-Overlapping Axis Label Bar Chart 9 - Inverted if Negative

Related Posts:

Learn how to create Excel dashboards.

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 [...]


Comment from Jeff Weir
Time: Tuesday, October 5, 2010, 7:19 pm

I love your ‘opposite’ approach, Jon. Somehow I missed this post when you posted it last year, and since then I’ve needlessly been using textboxes to display chart labels purely so I could have the flexibility to drag them out of the way. But this is way cooler.

Do you by any chance have a tutorial on here somewhere that deals with overlapping series labels? I’ve got a couple of charts that I’ve used your ‘label last point’ macro (excel 2007) in, but sometimes the two labels overlap.


Comment from Jon Peltier
Time: Wednesday, October 6, 2010, 7:24 am

Hi Jeff -

For specific projects I’ve often had algorithms for locating labels, using a hidden XY series to position the labels. Something like, if Y2>Y1 but Y2<Y1+Delta, then plot point (label) at Y1+Delta (and the other at Y2-Delta), where Delta was the minimum legible label spacing, dependent on axis scale.


Comment from Jeff Weir
Time: Wednesday, October 6, 2010, 3:00 pm

That’s a great back-door approach! And kinda obvious given the ‘opposite’ approach you mention in your post. I feel like I should have put 2 plus 2 together myself on this one :-)
Thanks Jon


Comment from Jon Peltier
Time: Wednesday, October 6, 2010, 3:40 pm

Jeff -

Y1+Delta and Y2-Delta aren’t exactly right, but I got it right in the code I posted under the other article:
Y1+(Delta-Abs(Y1-Y2))/2
Y2-(Delta-Abs(Y1-Y2))/2

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

Peltier Tech Chart Utilities for Excel Peltier Tech Waterfall Chart Utility Peltier Tech Box and Whisker Chart Utility Peltier Tech Cluster-Stack Chart Utility Peltier Tech Panel Chart Utility Peltier Tech Marimekko Chart Utility Peltier Tech Dot Plot Utility Peltier Tech Cascade Chart Utility

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