MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: BarChart3D with labels

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21336] Re: [mg21326] BarChart3D with labels
  • From: BobHanlon at aol.com
  • Date: Sun, 26 Dec 1999 01:26:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In my initial reply, I should have pointed out that the BarValues can be 
displayed in a default format by just setting the BarChart option BarValues 
to True

Needs["Graphics`Graphics`"];

lst1 = 20*Table[Random[], {5}];

BarChart[lst1, 
    BarLabels -> 
      Table["Group " <> ToString[k], {k, Length[lst1]}], 
    BarValues -> True, 
    PlotRange -> All];

However, to control the format of the BarValues, they need to be explicitly 
specified. In my initial reply I modified the precision of the BarValues. 
here I modify their precision and color (as well as the color of the 
BarLabels):

Needs["Statistics`DescriptiveStatistics`"];

colorFunc[x_?NumericQ, lst_List] := 
    Module[{mu = Mean[lst], sigma = StandardDeviation[lst]}, 
      If[Abs[x - mu] <= sigma, RGBColor[0, .75, 0], 
        If[x - mu > sigma, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]]];

BarChart[lst1, 
    BarLabels -> 
      Table[
        StyleForm["Group " <> ToString[k], 
          FontColor -> colorFunc[lst1[[k]], lst1]], 
        {k, Length[lst1]}], 
    Prolog -> 
      Table[
        Text[
          StyleForm[NumberForm[lst1[[k]], {4, 2}], 
            FontColor -> colorFunc[lst1[[k]], lst1]], 
          {k, lst1[[k]]}, {0, -1}], 
        {k, Length[lst1]}], 
    PlotRange -> All];

Bob Hanlon


  • Prev by Date: Re: BarChart3D with labels
  • Next by Date: RowBox-es
  • Previous by thread: Re: BarChart3D with labels
  • Next by thread: computing Dickman's function