9
$\begingroup$

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

$\endgroup$
17
$\begingroup$

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

| improve this answer | |
$\endgroup$
  • $\begingroup$ Your answer is excellent! $\endgroup$ – withparadox2 Jan 12 '13 at 1:29
  • $\begingroup$ @Mr.Wizard - thanks! #paradox2 - glad it helped! $\endgroup$ – Pinguin Dirk Jan 13 '13 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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