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] &]]
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:
Options[Legending`GridLegend]
{"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}
Answer
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:
SetOptions[Legending`GridLegend,
Legending`LegendContainer -> (Append[#, {Red, Bold, FontFamily -> "Helvetica"}] &) ]
BarChart[{{1, 2, 3}, {1, 3, 2}, {5, 2}},
ChartLegends -> {"some", "text", "here"} ]
Comments
Post a Comment