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.

This barchart was tricky to style, and I had to resort to the legacy BarCharts`package. Any ideas how to omit the labels from the bottom edge? Ideally I'd also like separator ticks between the column pairs.

data = {{-2.8, -5.8, -7.4, -9.2}, {-3.7, -6.8, -8.9, -11.8}};

colour1 = RGBColor[82/255, 85/255, 255/255];
colour2 = RGBColor[132/255, 178/255, 255/255];

Quiet[Needs["BarCharts`"]]

BarChart[data, Frame -> True, AxesOrigin -> {0, 0}, 
 PlotRange -> {{0.525, 4.825}, {-14, 0}},
 BarLabels -> {"March", "June", "September", "December"},
 BarGroupSpacing -> 0.3, BarSpacing -> 0, 
 BarStyle -> {colour1, colour2},
 BaseStyle -> {10, FontFamily -> "Verdana"}, AspectRatio -> 0.4, 
 ImageSize -> 350]

enter image description here

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Just some fun seeing how well I can dial it in by eye:

BarChart[Thread @ data,
 ChartStyle -> {colour1, colour2}, 
 ChartLabels -> {Placed[{"March", "June", "September", "December"}, Above], None},
 Frame -> True,
 FrameTicks -> {False, True}, 
 BaseStyle -> {10, FontFamily -> "Verdana"},
 BarSpacing -> {0, 0.8}, 
 PlotRangePadding -> {0.8, {2.2, 0}},
 AspectRatio -> 0.4, 
 ImageSize -> 350
]

recreation

original

share|improve this answer
    
That's great, thanks. And with FrameTicks freed up I can add the column separator ticks too, ie: BarChart[Thread@data, ChartStyle -> {colour1, colour2}, ChartLabels -> {Placed[{"March", "June", "September", "December"}, Above], None}, Frame -> True, FrameTicks -> {{True, True}, {False, Map[{#, Null} &, (Range[Length[First@data] - 1]*(2 + 0.8)) - 0.8/2]}}, BaseStyle -> {10, FontFamily -> "Verdana"}, BarSpacing -> {0, 0.8}, PlotRangePadding -> {0.8, {2.2, 0}}, AspectRatio -> 0.4, ImageSize -> 350] –  Chris Degnen May 30 '12 at 10:30
    
@Chris Thanks for the Accept. –  Mr.Wizard May 30 '12 at 10:37
    
I'm curious — did you feel this was significantly different from my answer? I guess I had just forgotten his ImageSize and AspectRatio... –  rm -rf May 30 '12 at 13:55
    
R.M I didn't intend my answer as complete (and I voted for yours); I just wanted to see how visually close I could get (I didn't actually look at his code for the purpose). FWIW I used BarSpacing, PlotRangePadding. I was hesitant to edit your answer with my messing about. I think your question implies that I should have. Would you have preferred that? Would you still prefer that? –  Mr.Wizard May 30 '12 at 17:43
1  
@R.M AAaahh! Hypno-Toad! –  Mr.Wizard May 31 '12 at 3:59

There is no need to use the deprecated BarCharts` package — you can create this chart using only built-in functions:

BarChart[Transpose@data, 
    ChartStyle -> {colour1, colour2}, 
    ChartLabels -> {Placed[{"March", "June", "September", "December"}, Above], None}, 
    Frame -> True, FrameTicks -> {False, True}, 
    BaseStyle -> {10, FontFamily -> "Verdana"}, BarSpacing -> {0, 0.3}, 
    AspectRatio -> 0.4, ImageSize -> 350, PlotRangePadding -> {0.4, 0.1}
]

enter image description here

share|improve this answer
1  
Adding PlotRange -> {All, {-0.25, -12}} removes the little gap between the boxes and the x-axis. edit: it kills the labels, though, oops. –  s0rce May 30 '12 at 3:12
    
@ R.M - thanks. It just needed the PlotRangePadding too. –  Chris Degnen May 30 '12 at 12:38
    
@ChrisDegnen Thanks, added the PlotRangePadding –  rm -rf May 30 '12 at 14:17

Like the other answers, I also suggest using the new BarChart. If you decide to stick with the BarCharts` package anyway, you can post process the ticks, like this:

Suppose the graphics object is named fig, then

{th, tv} = FrameTicks /. Options[fig, FrameTicks]

(* ==>
 {{{1.175, "March", 0}, {2.175, "June", 0}, 
  {3.175, "September", 0}, {4.175, "December", 0}}, Automatic}
)*

Show[fig, FrameTicks -> {{tv, tv}, {None, th}}]

Mathematica graphics

share|improve this answer
    
Thanks, that's what I was looking for. –  Chris Degnen May 30 '12 at 10:34

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.