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.

The question seems trivial, but no sign of such thing in reference. Also TicksStyle does not work for labels.

Thanks, Regards

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

Something like this?

BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}}, 
 ChartLabels -> {"a", "b", "c"}, 
 BaseStyle -> Directive[FontFamily -> "Zapfino", FontSize -> 16]]

zapfino

At first glance, the online documentation for BarChart doesn't describe any useful font options, but when you see the phrase "BarChart has the same options as Graphics with the following additions and changes", you realise that you can try the more general options that work for most 2D graphical output in Mathematica. So, although BaseStyle isn't shown in that list (since presumably there are no additions or changes specifically for BarChart), it works OK here.

In the same way, you can use Background to place a colored background behind a chart. It's not specifically listed in the documentation for BarChart, but once you know that Graphics options also apply, it's worth a try. Eventually, you'll be able to remember all the options, or you'll get there by trial and error. In my experience, the documentation probably contains the information you want, but it's not always on the first page you look at.

BarChart[{{1, 2, 3}, {1, 3, 2}},
 ChartLabels -> {"a", "b", "c"}, 
 ChartStyle -> "FruitPunchColors",
 BaseStyle -> Directive[FontFamily -> "Zapfino", FontSize -> 12],
 Background -> LightGray]

another graphic

share|improve this answer
1  
+1 best font choice ever :-) –  chris Mar 24 '13 at 16:44
    
@chris better than Comic Sans at least :) –  cormullion Mar 24 '13 at 17:54
add comment

For the specific task of styling BarChart labels I would use Style directly.

When using the BaseStyle option other elements are affected, potentially in undesirable ways, and some directives are not applied to the labels:

BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}},
 ChartLabels -> {"a", "b", "c"},
 BaseStyle -> Directive[Red, FontFamily -> "Stencil Std", FontSize -> 16]
]

Mathematica graphics

As you can see the axis lines are made red, which I did not desire, yet the A B C labels remain black. The style I desired may be produced with a more targeted approach:

lblStyle = Style[#, 16, Red, FontFamily -> "Stencil Std"] &;

BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}},
 ChartLabels -> lblStyle /@ {"a", "b", "c"}
]

Mathematica graphics

If you wish to style the 1 through 5 labels as well that can be done independently with LabelStyle:

BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}},
 ChartLabels -> lblStyle /@ {"a", "b", "c"},
 LabelStyle -> {22, Blue, Italic}
]

Mathematica graphics

share|improve this answer
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.