PTS Blog

Custom Solutions | Commercial Utilities | 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.

Legend Entry Tricks in Excel Charts

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

This is a continuation of Legends in Excel Charts – Formats, Size, Shape, and Position, which started a discussion about the legends in Excel charts. That article talked about legend formatting, and how the best legend is no legend at all: it’s more effective to put the text labels right on the data. But sometimes you just need a legend. The article also showed the default legend configurations, and showed how to change these to suit.

This article continues the discussion, showing how to use the legend components–legend entries and legend keys–to access more advanced legend functionality.

Legend Entries

Legend entries are treated somewhat independently of each other. You can select a legend entry with two single clicks, one to select the whole legend and the other to select the entry itself.

Legend Entry

You can format the text of the legend entry. I’ve bolded the legend entry “two” and to enhance the highlighting of this series I’ve used a thicker line in the chart.

Format the Legend Entry

You can selectively remove a legend entry by selecting it and deleting it, while leaving the series in the chart.

Deleting the Legend Entry Removes it From the Legend

In order to restore any legend entries to the legend, you must delete the whole legend, then add the default legend back to the chart, and reapply any custom formatting.

Don’t select the legend key before pressing the Delete key . . .

Legend Key

. . . because you will delete the series itself, not just the legend entry.

Deleting the Legend Key Deletes the Series

However, you can select the legend key then format it, which in turn formats the series in the chart.

Formatting the Legend Key Formats the Series

This last section does not apply to Excel 2007. You cannot select the legend entry in a chart in Excel 2007. I don’t know why this was changed, because it seemed a nice alternative way to access a series when you otherwise could not select it.

Multiple Legends in a Chart

Sometimes people want to split the legend into different parts. This is not possible. However, like many other visual effects in Excel charts, you can fake it. Here I have two charts, my working chart on the left, and a dummy chart on the right. In the working chart, I have removed the entries I don’t want in one of the legends. In the dummy chart I have removed the entries that are in the working chart’s legend.

Half of a LegendOther Half of a Legend

I then used a screen capture program (I use SnagIt) to copy the legend from the dummy chart, then I selected the working chart, and pasted this image into the chart, and moved it to where I wanted it.

Dual Legends

This is not a dynamic solution: if a label or series format changes, the static image which comprises the second legend may have to be refreshed. This is why I make a separate dummy chart as above. Both charts use the same data and series formats, so I only need to repeat the copy and paste to update my dual legend chart.

Follow up posts in the blog: Order of Legend Entries in Excel Charts, which describes some of the intricacies of legend entry order, and Double Legend in a Single Chart, which shows a dummy series trick to add multiple legends to a single chart.

Possibly Related Posts:

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

Learn how to create Excel dashboards.

Comments


Comment from Alistair Knock
Time: Wednesday, February 11, 2009, 8:32 am

Regarding multiple legends in a chart, it’s possible to do this dynamically by overlaying a transparent copy of the chart on top of itself, but in practice it isn’t worth the hassle of trying to get things pixel perfect. Set up the chart with all series and legends displayed, move legend on top of the chart, maximise the plot area, set the chart and object backgrounds to be transparent, turn off any ‘auto’ checkbox you see in the axes settings, then make a copy of the chart. Delete half the series from one and the other half from the other, and overlay one on top of the other (using the top left of the window helps here).

Both charts will then update in accordance with data changes, but you usually end up with some of the axes labels drifting away from other other… you could turn off everything on one chart, but on a complex graph there’s a niggling fear that the plotted points will do noticeably so as well.


Comment from Jon Peltier
Time: Wednesday, February 11, 2009, 8:40 am

Alistair -

Yep, this is possible, and as you say, it’s a lot of effort. Easier would be to scale the Y axis of the second chart so no points are visible, then hide EVERYTHING on the second chart except for the legend. No text, no lines, no borders, no fills. Keep all the series, of course, but they’re out of sight by being off scale. Now you don’t have to keep trying to align everything pixel by pixel.


Comment from derek
Time: Wednesday, February 11, 2009, 12:43 pm

Would it not be easier to have the top chart with no graph area border or fill, but a solid plot area, and the bottom chart with a solid border and fill, but a slightly smaller plot area hidden under the plot area of the top chart? No deleting of everything required, just shrinking the one chart plot area until it’s completely hidden under the other. The bottom legend must stay away from the top plot area, though.


Comment from Jon Peltier
Time: Wednesday, February 11, 2009, 12:58 pm

Derek -

If everything’s hidden, it will stay hidden. If a plot area is still visible, but behind the other chart’s plot area, any number of things may happen that cause the lower one to be seen.

Besides, your way won’t let you place both legends in front of the plot area the way my example shows.


Comment from Matt Healy
Time: Wednesday, February 11, 2009, 10:17 pm

One of my favorite tricks is to use one or more Text Box objects instead of legends on top of a Chart, because Text Boxes are much more flexible. Not only can they be formatted however one desires, but also a Text Box can have DYNAMIC content. Click on the Text Box, then type a cell reference into the Formula Bar and the value of that cell will be displayed in the Text Box, and then of course any formula one desires can go into that cell. I like to use Forms widgets like spinners or scrollbars in conjunction with OFFSET formulas so the contents of the Text Box change automagically.


Comment from Jon Peltier
Time: Wednesday, February 11, 2009, 10:44 pm

Matt -

Lots of ways to skin a cat. Textboxes are pretty flexible, but a legend entry can be equally dynamic. Put the formula into the cell referenced as the series name.


Comment from derek
Time: Thursday, February 12, 2009, 5:21 am

One headache I have regularly that y’all might be able to give me some ideas about is the opposite of multiple legends in one graph: one legend for multiple graphs. On one level it’s as easy as deleting the legends from all but one graph, but that’s often visually unbalanced. I sometimes end up creating a picture object to sit in a convenient spot in the middle of the group.


Comment from Jon Peltier
Time: Thursday, February 12, 2009, 6:31 am

I’ve done this the same as the dual legend trick. Say four charts have the same series, but look at different parameters. A 2 x 2 layout of charts is good, but four legends is overkill. So I make a fifth chart with all the series, but scale the axes so the data doesn’t appear, and hide all the other chart elements. This produces just a legend, which I move into the center of the layout.


Comment from derek
Time: Thursday, February 12, 2009, 7:36 am

So obvious now you mention it!

One other technique you (and Matt) might be interested in that I’ve used in the past is extra data series, for scatter charts or bubble charts. This was for when I wanted:

a) to comment on the meaning of error bars in a scatter chart. Making extra series lets me show and label a sample set of error bars.

b) to give a scale to bubble charts. Two or three sample bubbles would be labelled with their sizes, to enable the viewer to interpret the bubbles in the chart.

c) where I’ve used data labels instead of Excel symbols in scatter charts. Data labels can be much more complex in meaning than the small simplistic set of symbols available in Excel. But then I have to craft a custom legend for them.

d) as above, but where I’ve resorted to Autoshape drawings as symbols. This is fraught with potential for inaccuracy the way Excel draws shapes, but where I feel confident it works, I want a way to show the legend. Excel’s own legend facility produces awful squashed things in place of the proper shapes.


Comment from Jon Peltier
Time: Thursday, February 12, 2009, 8:04 am

Derek -

I love this out-of-the-box stuff. Panel charts are out-of-the-box, and I’ve reached further out to use dummy series each with one point and a data label to construct a custom legend in the corner of each panel.

The dummy bubble series is helpful to make sure the bubble sizes are consistent from one chart to the next. Make a bubble with the largest value you’d expect in any of the charts and add it to all charts. This largest bubble scales all the bobbles in the charts. I wrote about this in Control Bubble Chart Bubble Sizes.


Comment from Paul
Time: Tuesday, October 13, 2009, 4:33 am

Hello Jon, I am rather confused about something I thought maybe simple to do that is proving not and I am hoping from having read your articles here that you maybe able to assist.

When creating a simple line chart, I have 5 series of data, to the left of the chart is an area (using data validation by list) which allows the user to choose what they want to appear on the chart. This is done by 5 drop down boxes.

If the user chooses a blank because they only want to show for example 4 series of data then choosing the blank obviously removes the data from the graph. However it still leaves the series line in the legend. So what I need to try and find out is how to remove the line series when a blank is selected and if something is selected then to put the series line back into the legend…….any ideas ?


Comment from Jon Peltier
Time: Tuesday, October 13, 2009, 7:44 am

Paul -

This requires VBA to add and remove the series from the chart, or to apply an autofilter that hides rows without data (Excel’s default is to skip plotting of hidden data). The other option is to skip the legend but label the series directly, as in Label Each Series in a Chart and Label Last Point for Excel 2007. When the series is suppressed, so is its label.

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.