MathGroup Archive 2009

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

Search the Archive

Re: ChartLabels for Stacked, Grouped BarCharts?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105839] Re: [mg105816] ChartLabels for Stacked, Grouped BarCharts?
  • From: Brett Champion <brettc at wolfram.com>
  • Date: Mon, 21 Dec 2009 03:31:44 -0500 (EST)
  • References: <200912201154.GAA01009@smc.vnet.net>

On Dec 20, 2009, at 5:54 AM, Gordon Robertson wrote:

> Could I ask for help with ChartLabels for Stacked and Grouped 
> BarCharts in
> Mathematica 7? I've checked the MathGroup archives and Mathematica 
> help docs.
>
> I need to assess Stacked and Grouped BarCharts for a 2D dataset that
> consists of 20 groups of three values. Labels for the groups are
> {31,32,...,50}. From the help docs, it's easy to display the bars in 

> either
> mode for simple baseline cases. But I don't see how to put a 
> *single* label
> or tick *per stack or group*, below the X-axis.
>
> The following simulates the 2D dataset that will be read in from a 
> file:
> tab2 = {{"a",1,2,3},{"b",2,3,4},{"c",3,4,5}}
>
> labs2 = tab2[[All,1]]
>
> data2 = tab2[[All,2;;4]]
>
>
> I need "Stacked" and "Grouped" BarCharts that have "a","b" and "c",
> respectively, as the labels for the three bar stacks or groups, 
> below the
> X-axis. The following commands do not give this:
> BarChart[data2,ChartLayout->"Stacked",ChartLabels-
> >Placed[labs2,Below]]
> BarChart[data2,ChartLayout->"Grouped",ChartLabels-
> >Placed[labs2,Below]]
>
> The "Stacked" graph has a vertical stack of "a" "b" and "c" below 
> the lower
> edges of *each* block in *each* bar/block stack; the "Grouped" graph 
> has a
> label beneath *each* bar. Likely this makes sense in terms of 
> general 'list '
> rules, but it does not deliver what I need.
>
> I've tried expanding the label list and using a list that includes 
> None for
> the second argument of Placed[], but have not quickly found a 
> solution.
>
> I can guess that Ticks may be the approach to use, but wonder if I 
> could as k
> more experienced folks for help. Could I also ask WRI to implement (or
> document) these BarChart use cases.
>

It sounds like you want:

BarChart[data2, ChartLayout -> "Stacked", ChartLabels -> 
{Placed[labs2, Below], None}]
BarChart[data2, ChartLayout -> "Grouped", ChartLabels -> 
{Placed[labs2, Below], None}]

Examples with this behavior in the documentation (not a comprehensive 
list):

BarChart > Examples > Scope > Labeling and Legending > "For rows of 
data"
BarChart > Examples > Options > ChartLabels > "Associate labels with 
rows or datasets:"
BarChart > Examples > Applications > (Portfolio example)
ChartLabels > Examples > Basic Examples > (third example)

and is generally covered by

"ChartLabels->{spec1,spec2,=85} uses the successive  speci to specify 
labels for successive dimensions in nested lists of datasets." in the 
ChartLabels documentation.

Note that ChartLabels, ChartLegends, ChartElements have similar 
behavior.

Brett Champion
Wolfram Research



  • Prev by Date: Re: ChartLabels for Stacked, Grouped BarCharts?
  • Next by Date: Re: ChartLabels for Stacked, Grouped BarCharts?
  • Previous by thread: ChartLabels for Stacked, Grouped BarCharts?
  • Next by thread: Re: ChartLabels for Stacked, Grouped BarCharts?