Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Barchart' topicStudent Support Forum > General > Archives > "Barchart"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
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: ,

Subject (listing for 'Barchart')
Author Date Posted
Barchart mathematica ... 10/08/12 1:06pm
Re: Barchart yehuda 10/11/12 6:21pm
Re: Barchart mathematica ... 10/12/12 4:18pm
Re: Re: Barchart yehuda 10/14/12 6:25pm
Re: Re: Re: Barchart mathematica ... 10/17/12 4:05pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic