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.

Possible Duplicate:
How can I influence the spaces between labels on a BarChart

How can I avoid label collisions in plot ticks and labels? For example, here is a histogram with colliding frame tick labels:

BarChart[{Labeled[{196}, Row[{"Jan", "Feb 23"}, "-"], Below], 
  Labeled[{349}, Row[{"Feb 23", "Apr 15"}, "-"], Below], 
  Labeled[{333}, Row[{"Apr 15", "Jun 6"}, "-"], Below], 
  Labeled[{308}, Row[{"Jun 6", "Jul 28"}, "-"], Below], 
  Labeled[{308}, Row[{"Jul 28", "Sep 19"}, "-"], Below], 
  Labeled[{344}, Row[{"Sep 19", "Nov 10"}, "-"], Below], 
  Labeled[{162}, Row[{"Nov 10", "Jan"}, "-"], Below]}, 
 GridLines -> {Automatic, None}, 
 BaseStyle -> Directive[FontFamily -> "Bitstream Charter", 10], 
 BarSpacing -> 0, Ticks -> None, GridLines -> None, 
 Frame -> {{True, False}, {False, False}}, PlotRange -> All, 
 BarOrigin -> Bottom, BarSpacing -> None, ChartLayout -> "Stacked", 
 PerformanceGoal -> "Speed", 
 ChartStyle -> {Directive[
    EdgeForm[{Opacity[1.`], Thickness[Medium], Blue}], Opacity[1.`], 
    FaceForm[LightBlue]]}]

Mathematica graphics

So the question has two parts:

  1. How to detect collisions in frame tick labels in general.
  2. How to rearrange labels to minimize collisions and optimize for aesthetics.

I'm not sure how to do part 1, but part 2 should involve either rotations or columns I guess. I would rather not assume a specific font or size of text, but perhaps this is unavoidable.

share|improve this question
    
I do not see the example histogram. –  Davorak Sep 10 '12 at 19:48
    
Weird, I can't upload images. The toolbar is gone! What should I do? I've tried restarting safari. –  M.R. Sep 10 '12 at 19:49
3  
Stay with us. Don't look down. Breath slowly and deep- –  belisarius Sep 10 '12 at 19:52
    
You could use Szabolcs' picture upload tool to directly upload graphics from Mathematica to StackExchange. –  Sjoerd C. de Vries Sep 10 '12 at 20:18
    
Ok, I did, but my code still isn't code. –  M.R. Sep 10 '12 at 20:36
show 2 more comments

marked as duplicate by rm -rf, rcollyer, F'x, Yves Klett, Eli Lansey Sep 11 '12 at 16:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

You can rotate the labels like this:

rot[x_] := Rotate[x, \[Pi]/2]

BarChart[{Labeled[{196}, rot@Row[{"Jan", "Feb 23"}, "-"], Below], 
  Labeled[{349}, rot@Row[{"Feb 23", "Apr 15"}, "-"], Below], 
  Labeled[{333}, rot@Row[{"Apr 15", "Jun 6"}, "-"], Below], 
  Labeled[{308}, rot@Row[{"Jun 6", "Jul 28"}, "-"], Below], 
  Labeled[{308}, rot@Row[{"Jul 28", "Sep 19"}, "-"], Below], 
  Labeled[{344}, rot@Row[{"Sep 19", "Nov 10"}, "-"], Below], 
  Labeled[{162}, rot@Row[{"Nov 10", "Jan"}, "-"], Below]}, 
 GridLines -> {Automatic, None}, 
 BaseStyle -> Directive[FontFamily -> "Bitstream Charter", 10], 
 BarSpacing -> 0, Ticks -> None, GridLines -> None, 
 Frame -> {{True, False}, {False, False}}, PlotRange -> All, 
 BarOrigin -> Bottom, BarSpacing -> None, ChartLayout -> "Stacked", 
 PerformanceGoal -> "Speed", 
 ChartStyle -> {Directive[
    EdgeForm[{Opacity[1.`], Thickness[Medium], Blue}], Opacity[1.`], 
    FaceForm[LightBlue]]}]

Example barchart with rotated labels

share|improve this answer
add comment

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