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 have labeled the name(A,B,C) of each row on the left and value of each item , is there any way to put the total number(6,7,5) of each row on the right side without changing other labels?

BarChart[{{1, 2, 3}, {2, 4, 1}, {3, 1, 1}}, BarOrigin -> Left, 
 ChartLayout -> "Stacked", BarSpacing -> 0.5, 
 ChartLabels -> {Placed[{"A", "B", "C"}, Before], None}, 
 LabelingFunction -> (Placed[#1, Center] &)]

enter image description here

share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

Maybe this helps:

BarChart[#, BarOrigin -> Left, ChartLayout -> "Stacked", 
 BarSpacing -> 0.5, 
 ChartLabels -> {Placed[{{"A", "B", "C"}, {Total@#[[1]], 
 Total@#[[2]], Total@#[[3]]}}, {Before, After}], None}, 
 LabelingFunction -> (Placed[#1, Center] &)] &@{{1, 2, 3}, {2, 4, 1}, {3, 1, 1}}

EDIT: slightly cleaner:

BarChart[#, BarOrigin -> Left, ChartLayout -> "Stacked", 
 BarSpacing -> 0.5, 
 ChartLabels -> {Placed[{{"A", "B", "C"}, Total@#}, {Before, After}], None}, 
 LabelingFunction -> (Placed[#1, Center] &)] &@{{1, 2, 3}, {2, 1, 1}, {3, 1, 1}}

enter image description here

share|improve this answer
    
Your answer is excellent! –  withparadox2 Jan 12 '13 at 1:29
    
+1 and enjoy your first Enlightened badge. –  Mr.Wizard Jan 12 '13 at 17:09
    
@Mr.Wizard - thanks! #paradox2 - glad it helped! –  Pinguin Dirk Jan 13 '13 at 7:45
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.