Colors in Chart Labels [Quick Tip]

Posted on January 29th, 2009 in Charts and Graphs , Learn Excel - 23 comments

This post is part of our spreadcheats series – 30 Excel and Charting Tips & Hacks aimed to make day to day spreadsheeting fun and productive.

One of the most common charts is “YoY Growth Rates of Our Superawesomekickass Product”. While not everyone may have a superawesomekickass product, most of us in fact make a YoY (Year on Year) growth rate charts for various types of data.

A simple label formatting hack can improve the effectiveness of these charts by adding color to differentiate positive vs. negative growth (or mediocre vs. sky rocketing growth rates). See this example:

Excel Chart - Colors in Data Labels - How to

You can get this effect by applying custom number formatting to the data label. It is one of my favorite tricks in excel and I have written about it in introduction to custom cell formatting in excel, number formatting in excel using custom codes, showing decimal values only when needed articles.

How you can get colors in Axis Labels

First apply data labels to your chart and now select the data labels and press ctrl+1 (aww, come on now, you are reading this blog, you should what ctrl+1 means) and go to numbers tab. Select “custom” as category and specify the formatting code like this:

custom format code for getting colors in chart labels

[blue]+0%;[red]-0%

Now, that was easy, isn’t it. But you might think, “Chandoo, what the heck the above format code is doing?”

Well, it tells excel to apply red color and add a minus symbol if the data label value is less than zero and apply blue color and add + symbol if the value is above zero. You see the custom number formatting codes have 3 parts in them, like this:

formatting for positive numbers ; formatting for negative numbers ; formatting for zero values

If you are noob (hi noob!) and lost in all these codes and square brackets, you may want to checkout our post on introduction to number formatting in excel to learn more about custom codes.

Ok, that was fun, What else you can do?

You can do much more using custom codes to format data labels. For example, a code like [Red][<0.15]0%;[Blue][>=0.15]0%; will, Oh, forget it, you can guess that. Just remember that excel allows only 3 parts in custom codes. So go nuts, but just thrice.

Like this post, I mean REALLY like it?

Awesome, You should  sign up for e-mail updates or get our full RSS Feeds so that you never miss a post.

Why you should never miss a post? Because my friend, one of the posts might help you make your product superawesomekickass.

Your email address is safe with us. Our policies

Written by Chandoo
Tags: , , , , , , , , ,
Home: Chandoo.org Main Page
? Doubt: Ask an Excel Question

23 Responses to “Colors in Chart Labels [Quick Tip]”

  1. Sam Krysiak says:

    I’ve been looking for a way to include colour-coded chart labels without applying the formatting manually. Great tip!

  2. Sumit Dhar says:

    Chandoo, it is possible to format the bar colors in the chart based on the values?

    Cheers,
    Dhar

  3. derek says:

    Sumit, the trick is to use lateral thinking and create two bar series: one colour is when you want it blue and zero when you don’t, and the other colour is the other way round.

  4. Chandoo says:

    @Sam: thanks
    @Sumit: as Derek suggested, the trick lies in creating multiple series and completely overlapping them so that you see color as per your need.

  5. Govert says:

    Superb tip! Thanks!

  6. Sumit Dhar says:

    Derek / Chandoo,

    Thanks for your inputs.

    Cheers,
    D.

  7. David H says:

    Chandoo,

    Can you provide an example of this:

    “@Sam: thanks
    @Sumit: as Derek suggested, the trick lies in creating multiple series and completely overlapping them so that you see color as per your need.”

    Thanks!
    David

  8. Chandoo says:

    @David: Sure, I will make a note of this topic and write about it in the coming weeks :)

  9. [...] flashy formatting, 3d pie charts, 3d donuts and layered donuts etc. Also, whenever possible, try Using data labels, using color and if nothing works, try using other types of charts for comparison. After all, we [...]

  10. David says:

    A few weeks ago, Chandoo posted some Excel Tips and mine was one of those tips. I created a KPI spreadsheet that changed the format of numbers and the colors of the chart based on the table of data below the chart. (See original post: http://chandoo.org/wp/2009/05/11/excel-tips-by-you-1/). Maybe this would be helpful. I still want to post a blog entry on this but due to budget problems in our state, I don’t have the time. Soon…

  11. Vanessa says:

    Hi Chandoo!
    Is there a way I can make the labels show white doing this? I tried [White]-0.0% but it gives me a white font with a black background… I wanted the labels to be “invisible” in case it is less than zero!

    • Chandoo says:

      @Vanessa.. you can do that by using a formatting code like 0.0%;;0% (the middle portion of the formatting code tells how negative numbers should be shown, and we are telling excel to show nothing if the number is negative)

      Also, the if you want use the WHITE color, then you need to set the label background color to transparent. This can be done by selecting labels, hitting format labels option, and then in the label background color area (from font tab) you can set the background color to be transparent (the default value is automatic or something like that…)

  12. sonato says:

    hey!
    Its very good
    when I first saw it, I said: oh but this too, I could do it easily manually
    but when I did it, I really saw the beauty that accompanies it.
    Thanks

  13. jeremy says:

    i want to setup conditional formatting on a chart label, based on a cell that is not a part of the data range. i.e. i want the 90% label on a bar chart to be bold and underlined when cell A1=1, when cell A1=0 no formatting.

    is this possible? (excel 2000)

    cheers

  14. Chandoo says:

    @Sonato: Thank you :)

    @Jeremy: Welcome to PHD and thanks for commenting. I am not aware of a simple way to conditionally format axis labels. You can try using some macros though. But the best thing would be use as few colors as possible. This looks both aesthetically pleasing and takes less time.

  15. keith says:

    Hi Chandoo,

    I am making a line chart to display numbers between 0 and say 30. I have upper and lower limit lines at 4 and 10. What would be the easiest way to make numbers outside those limits display red while leaving the numbers between 4 and 10 green. I am new at this and tried entering custom functions/formulas but cant get it right.

    Thanks
    P.S. Excel 2003

  16. [...] Show colors in Chart Labels, Axis Labels > Show symbols in Chart Labels, Axis > 5 Chart Formatting Tricks > More charting tutorials [...]

  17. Jo Ann says:

    I greatly appreciate that you are sharing your considerable talent.

    Quantitative information is useful and important. Your talent in showing how non-quantitative types can more easily read visual information is invaluable. Thank you.

    I must add, that I have resisted learning excel for years. But, your friendly, bit size lessons are the best.

    Jo Ann Goldberg

  18. maddy says:

    1st – Thank you for having this awesome blog! It totally rocks.
    2nd – I’ve done the data labeling as mentioned here and it works, but when i use the XY Data Labeller, i cant format the labels anymore. How would i be able to format the data labels after adding the labels using XY Data Labeler?
    Thanks!!
    Maddy

  19. Fabio says:

    WHOA!

    Thanks!

    Greetings from Brazil!

Leave a Reply