| Author |
Comment/Response |
yehuda
|
10/14/12 6:25pm
In Response To 'Re: Barchart' --------- Well, if this is all you want, just use LabelingFunction->Pos
where pos is on of Left, Center, Right, Top, Bottom
see the following code. I added some simple code that would print the sum on the top of each stacked bar
oldNumbers = {20, 30, 40};
newNumbers = {1.2, 1.4, 1.6}*oldNumbers
{sumOld, sumNew} = Total /@ {oldNumbers, newNumbers};
BarChart[{oldNumbers, newNumbers}, LabelingFunction -> Right
, ChartLayout -> "Stacked",
Epilog ->
MapIndexed[
Text[Style[#, Red, 14, Bold], {#2[[1]], #1 + 5}] &, {sumOld,
sumNew}], PlotRange -> {0, 140}]
This way is uses default text parameters for the values. If you want to change them, you need to combine Placed and Style and define it as a function of a single argument. The function uses # denote its first argument and & to denote that it is a function. It should be surrounded with parentheses since the required returned value is a function
oldNumbers = {20, 30, 40};
newNumbers = {1.2, 1.4, 1.6}*oldNumbers
{sumOld, sumNew} = Total /@ {oldNumbers, newNumbers};
BarChart[{oldNumbers, newNumbers},
LabelingFunction -> (Placed[Style[#, Red, 12, Bold], Right] &)
, ChartLayout -> "Stacked",
Epilog ->
MapIndexed[
Text[Style[#, Blue, 14, Bold], {#2[[1]], #1 + 5}] &, {sumOld,
sumNew}], PlotRange -> {0, 140}]
HTH
yehuda
URL: , |
|