Re: Orientation of BarChart labels

• To: mathgroup at smc.vnet.net
• Subject: [mg35187] Re: [mg35185] Orientation of BarChart labels
• From: Omega Consulting <omega_consulting at yahoo.com>
• Date: Sat, 29 Jun 2002 01:37:43 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```At 01:32 AM 6/28/2002, Coleman, Mark wrote:
>Greetings
>
>I am creating bar charts for values that have fairly long names. The
>default BarLabels option depicts the labels horizontally, causing the
>labels to over run eachother and make the chart unreadable. Is there a way
>to alter the orientation of the bar labels to veritical?
>
>Thanks,
>
>-Mark

BarChart uses Ticks (or FrameTicks) to create the BarLabels. Ticks and
FrameTicks cannot be rotated, however. So you need to replace them with
Text primitives.

Create the BarChart.

In[1]:=
<<Graphics`

In[2]:=
bc=BarChart[{1,-3,4,5,2,3},{3,6,4,3},
BarLabels->{"axxxxxxxxxx","bxxxxxxxxxx","cxxxxxxxxxx","dxxxxxxxxxx",
"exxxxxxxxxx","fxxxxxxxxxx"}]

Then we extract the Ticks for the BarLabels.
In[3]:=
labels = First[Ticks/.Options[bc, Ticks]]

Out[3]=
{{1.2,axxxxxxxxxx},{2.2,bxxxxxxxxxx},{3.2,cxxxxxxxxxx},{4.2,dxxxxxxxxxx},{5.2,
exxxxxxxxxx},{6.2,fxxxxxxxxxx}}

Convert the labels to Text primitives.

In[4]:=
LabelToText[{x_, txt_}] := Text[txt, {x, 0}, {0,1}, {0,1}]

In[5]:=
text = Map[LabelToText, labels]

Out[5]=
{Text[axxxxxxxxxx,{1.2,0},{0,1},{0,1}],Text[bxxxxxxxxxx,{2.2,0},{0,1},{0,1}],
Text[cxxxxxxxxxx,{3.2,0},{0,1},{0,1}],Text[dxxxxxxxxxx,{4.2,0},{0,1},{0,1}],
Text[exxxxxxxxxx,{5.2,0},{0,1},{0,1}],Text[fxxxxxxxxxx,{6.2,0},{0,1},{0,1}]}

Remove the Ticks and insert the Text.

In[6]:=
Show[{bc, Graphics[text]}, Ticks->{None,Automatic}, PlotRange->All]

--------------------------------------------------------------
Omega Consulting