The question seems trivial, but no sign of such thing in reference. Also TicksStyle
does not work for labels.
Thanks, Regards
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityThe question seems trivial, but no sign of such thing in reference. Also TicksStyle
does not work for labels.
Thanks, Regards
Something like this?
BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}},
ChartLabels -> {"a", "b", "c"},
BaseStyle -> Directive[FontFamily -> "Zapfino", FontSize -> 16]]
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]
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]
]
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"}
]
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}
]