Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Gustavo Delfino's answer to an earlier question showed that it is possible to use the third argument to Placed to format text in a BarChart legend as desired. For example, without this argument, the legend text in the example below would still be small and in Times, even though I have used SetOptions to style BaseStyle for BarChart, Graphics, etc.

BarChart[RandomVariate[NormalDistribution[0, 0.6], 40], 
 ChartStyle -> Join[ConstantArray[Green, {39}], {Orange}], 
 ChartLegends -> Placed[Join[ConstantArray[None, {39}], {"Preliminary estimates"}], 
   Bottom, Style[#, FontFamily -> "Arial", FontSize -> 14] &]]

enter image description here

Is there a way to set this globally? I’d like to enforce the font style of legends in a package, the way I have already done for the frame around the legend using Mr.Wizard’s answer to an earlier question of mine on StackOverflow. I would have thought some setting of BaseStyle should work but these are the only (undocumented) options that Legending`GridLegend takes:


{"LegendPlacementFunction" -> Automatic, 
 LegendAppearance -> Automatic, 
 Legending`LegendContainer -> Automatic, 
 Legending`LegendHeading -> None, Legending`LegendImage -> Automatic, 
 Legending`LegendImage -> Automatic, 
 Legending`LegendLayout -> Automatic, 
 Legending`LegendPosition -> Automatic, 
 Legending`LegendSize -> Automatic}
share|improve this question
If it's a package, then why not supply a custom barchart function that applies the styling in the definition, thereby hiding it from the end-user? – R. M. Jun 3 '12 at 16:34
@R.M actually it is already a custom barchart function, but I'm trying to work out how to introduce simple legending into that function. Or I could just leave it to the successful tender for the contract to write the GUI. – Verbeia Jun 3 '12 at 23:48
makes more sense to leave it to the latter. They probably have that sorted. – Mike Honeychurch Jun 4 '12 at 0:22
@MikeHoneychurch :) – Verbeia Jun 4 '12 at 1:34
up vote 3 down vote accepted

I'm not certain I understand your requirements, but if you liked my prior answer that you referenced, why not use it here too? Since the LegendContainer is applied to the legend you can use it to insert directives:

  Legending`LegendContainer -> (Append[#, {Red, Bold, FontFamily -> "Helvetica"}] &) ]

BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}}, 
  ChartLegends -> {"some", "text", "here"} ]

Mathematica graphics

share|improve this answer
Thanks! I hadn't realised that this could be done as well as including the Identity trick in your last answer. (There's a blog post in here somewhere...) – Verbeia Jun 4 '12 at 12:05
@Verbeia similar use: – Mr.Wizard Jun 9 '12 at 8:57

Your Answer


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.