Screwy use of Labeled in BarChart -- possible bug
This looks like a bug. I'll seek confirmation from WRI and post accordingly. In the meantime Carl's suggestion is a work around:
BarChart[Labeled[#, Rotate["label", 90 Degree], Above, Directive[Red, FontSize
-> 32]] & /@ Range[8]]
or alternatively from @kglr:
BarChart[Labeled[#, Style[Rotate["label", 90 Degree], Red, 32], Above] & /@ Range[8]]
It appears there is a missing step in the processing of LabelStyle
within the Labeled
wrapper, if it is to work as desired. I think Carl Woll's work-around does this manually but it should be done automatically.
Most of the options of Labeled
apply not to the labels themselves but either to be object being labeled, e.g. Background
and Frame
, or affect the overall layout e.g. Spacings
and ImageSize
. I think it makes sense for these options to be ignored by BarChart
as it has its own directives for these aspects.
Attempting to dig through the Charting`
definitions it is hard to know where exactly handling of LabelStyle
should have been applied.
We can get some possibly useful information by turning on Charting debug printing:
Charting`dbPrint = Print;
Now:
SetOptions[BarChart, LabelStyle -> {}];
BarChart[
Labeled[#, "label", Above,
LabelStyle -> Directive[Red, FontSize -> 32]] & /@ Range[8]
]
iBarChart via: BarChart
ChartParser: hasWrappedInputQ: True
ChartParser: WrapperFunctions: {{1}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{2}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{3}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{4}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{5}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{6}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{7}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}},{8}->{{Labeled,label,Above,LabelStyle->Directive[,FontSize->32]}}}
.
.
.
Wrappers defined in Charting`ParserDump`$ApplicationWrapperFunctions
which include Labeled
appear to be handled generically.
Charting`ChartParser
is used to process the chart data. It calls
Charting`ParserDump`processWrappers
which contains the definition:
(* contexts stripped for brevity *)
processWrappers[obj_, d : h_[x_, y___], pos_, wrappers_List] /;
MemberQ[wrappers, h] :=
Module[{data},
appendProperty[obj,
"WrapperFunctions", {pos ->
Which[MemberQ[$SystemWrapperFunctions, h], data = x; {h, h[#1, y] &},
MemberQ[$ApplicationWrapperFunctions, h], data = x; {h, y},
MemberQ[$MetaWrapperFunctions, h], data = x; {h, y},
MemberQ[$ModelWrapperFunctions, h], data = d["InputData"]; {h, d}, True,
dbPrint["processWrappers: ", h, " is not in any of the wrapper lists. "]]}];
processWrappers[obj, data, pos, wrappers]
]
Note that for every Application Wrapper Function the same transformation is applied, i.e. wrapper[foo, bar, baz]
-> {wrapper, bar, baz}
.
I get lost in the definitions here but I cannot find anything that would handle LableStyle
specifically.