Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to create a stacked BarChart where each BarChart has different ChartLabels. Consider the following example:

BarChart[{{5, 6, 7, 5, 7}, {8, 5, 6, 7, 8}}, ChartLayout -> "Stacked",
  ChartLabels -> {Placed[{"One", "Two"}, Above], 
   Placed[{5, 6, 7, 5, 7}, Center]}]

enter image description here

But what I would like to have is separate labels for the segments in the two chart elements. The following image illustrates this:

enter image description here

I can't figure out how to do that using ChartLabels. When I try providing multiple lists for the chart labels it doesn't work.

share|improve this question
    
Here it is BarChart[{{5, 6, 7, 5, 7}, {8, 5, 6, 7, 8}}, LabelingFunction -> (Placed[#1, Center] &), ChartLayout -> "Stacked"] –  Öskå Sep 19 '13 at 13:55
    
possible duplicate of Label both sides in BarChart –  Pinguin Dirk Sep 19 '13 at 14:02
    
Not sure if it is a dupe, have a look if it helps –  Pinguin Dirk Sep 19 '13 at 14:03
add comment

1 Answer

up vote 6 down vote accepted

This and this give the answer by using LabelingFunction. Thus you can use

BarChart[{{5, 6, 7, 5, 7}, {8, 5, 6, 7, 8}}, 
  LabelingFunction -> (Placed[#1, Center] &), 
  ChartLayout -> "Stacked"]

And have:

Tada!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.