There are a lot of questions here about formatting of barcharts, but I couldn't find one matching mine. I seek to display data in stacked format, labeling each component of the stack and the total for each bar. I can't make it work for the life of me.

As a starting place, consider

BarChart[{{1, 2}, {2, 3}, {2, 4}}, ChartLayout -> "Stacked", 
 ChartLabels -> {Range[2004, 2006], None}]

I want each component labeled as below --


My efforts to date result in some pieces appearing but never all, and often in the wrong places.


1 Answer 1

BarChart[Labeled[#, Total[#], Above] & /@ {{1, 2}, {2, 3}, {2, 4}}, 
         ChartLayout -> "Stacked", ChartLabels -> {Range[2004, 2006], None}, 
         LabelingFunction -> (Placed[#1, Center] &)]

enter image description here

  • $\begingroup$ +1 was about to post but you got there while I was still eating my breakfast :) $\endgroup$ Commented Jun 12, 2014 at 22:52
  • $\begingroup$ @MikeHoneychurch: LOL, I'm usually last to the party re:plotting/graphics against you and other plot wizards - it just happens I needed this very layout not long ago... thanks for + ! $\endgroup$
    – ciao
    Commented Jun 12, 2014 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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