Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a BarChart (Mathematica 9.0.1)

BarChart[{1, 2, 3},
ChartLabels -> (Rotate[Text[Style[#, FontSize -> Scaled[0.05]]], -Pi/2]
& /@{abcdabcd,abcdabcd, abcdabcd})]

enter image description here

and would like to add a vertical label to the y-axis. I tried

BarChart[{1, 2, 3},
ChartLabels -> (Rotate[Text[Style[#, FontSize -> Scaled[0.05]]], -Pi/2]
& /@ {abcdabcd, abcdabcd, abcdabcd}),
FrameLabel -> {None, "y-axis"},
Frame -> {False, True, False, False}]

and it's perfect except for a gap between the two axes (which is somehow extremely ugly with the actual data):

enter image description here

I tried using Labeled, but then the label is positioned too low (i want it at the center of the y-axis):

Labeled[BarChart[{1, 2, 3},
ChartLabels -> (Rotate[Text[Style[#, FontSize -> Scaled[0.05]]], -Pi/2]
& /@ {abcdabcd, abcdabcd, abcdabcd})],
{Rotate[Style["y-axis", FontFamily -> "Helvetica"], Pi/2]}, {Left}]

(Can't post > 2 links)

Any help would be most appreciated!

share|improve this question
    
Welcome, Stefan. I embedded the images for you. The image/link limitation is an anti-spam measure that will be lifted once you start using the site more. –  Mr.Wizard May 18 '13 at 14:07
    
@Silvia: If I try that, the gap is gone, but so is the label ('y-axis'). –  Stefan Ca May 18 '13 at 17:24
    
Oops, you're right. Sorry for my oversight.. –  Silvia May 18 '13 at 17:42
add comment

2 Answers 2

up vote 1 down vote accepted

In your second attempt (which results in the gap), you can remove the gap by eliminating the PlotRangePadding for the x-axis.

PlotRangePadding -> {0, 0}
share|improve this answer
    
You're right, that's even a bit simpler than Mr. Wizards solution. –  Stefan Ca May 18 '13 at 17:28
    
@Stefan For what it's worth the output (from this) looks a bit different on version 7, and the longer code was required to match your output. Also, I believe you should be able to use the slightly shorter PlotRangePadding -> 0 to produce the same output as given by PlotRangePadding -> {0, 0}. –  Mr.Wizard May 19 '13 at 5:52
add comment

This feels a lot more complicated than it should be, but I think at least it works:

BarChart[{1, 2, 3},
 ChartLabels ->
  (Rotate[Text[Style[#, FontSize -> Scaled[0.05]]], -Pi/2] & /@ {abcdabcd, abcdabcd, abcdabcd}),
 FrameLabel -> {None, "y-axis"},
 Frame -> {1, 1, 0, 0},
 FrameTicks -> {None, All},
 PlotRangePadding -> {0.1, 0}
]

enter image description here

share|improve this answer
    
Thank you very much! It's exactly what a needed. –  Stefan Ca May 18 '13 at 14:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.