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.

Just wondering if anyone knows the proper Syntax to change the Text properties in the BarChart's ChartLegend. I cannot seem to figure out how to get Style[] to apply. Here is an example:

BarChart[{1, 2, 3}, ChartStyle -> "Pastel", 
 ChartLegends -> Placed[{"John", "Mary", "Bob"}, Bottom]]

BarChart[{1, 2, 3}, ChartStyle -> "Pastel", 
 ChartLegends -> Placed[Style[{"John", "Mary", "Bob"},
  FontFamily->"Courier"], Bottom]]

Any help would be greatly appreciated.

t.

share|improve this question

3 Answers 3

Map[] (i.e., /@) does the trick:

BarChart[{1, 2, 3}, ChartStyle -> "Pastel", 
 ChartLegends -> 
  Placed[Style[#, FontFamily -> "Courier"] & /@ {"John", "Mary", "Bob"}, Bottom]]

bar chart example

share|improve this answer

Actually you can do it without using Map[] as Placed[] takes a third optional argument for cases like this:

BarChart[{1, 2, 3}, ChartStyle -> "Pastel", 
 ChartLegends -> 
  Placed[{"John", "Mary", "Bob"}, Bottom, Style[#, FontFamily -> "Courier"] &]]
share|improve this answer

One can also do this globally with Legending`LegendContainer:

SetOptions[Legending`GridLegend,
  Legending`LegendContainer -> (Framed @ Append[#, FontFamily -> "Mathematica6"] &)
];

BarChart[{1, 2, 3},
  ChartStyle -> "Pastel", 
  ChartLegends -> Placed[{"John", "Mary", "Bob"}, Bottom]
]

Mathematica graphics

This works because the expression passed to the LegendContainer function has head Style, and Append therefore inserts the given style.

share|improve this answer

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.