BarChart
is aggravating. Why don't the following correctly display both percentages and labels?
(1)
BarChart[{{1,2,3}},
ChartLayout -> "Stacked",
ChartLabels ->
{Placed[{"17%", "33%", "50%"}, Center, Style[#, FontFamily -> "Helvetica", 11]&],
Placed[{"aa", "bbb", "cccc"}, After, Style[#, FontFamily -> "Helvetica", 14]&]},
AspectRatio -> 2,
ImageSize -> 100]
The text labels are rendered correctly (based on an A to a similar Q by Pinguin Dirk here, turns out that the After
option left-justifies the text, while numerical parameters don't, even with TextAlignment -> Left
set in Style
):
I have also tried using LabelingFunction
:
(2)
BarChart[{{1, 2, 3}}, ChartLayout -> "Stacked",
ChartLabels ->
Placed[{"aa", "bbb", "cccc"}, After,
Style[#, FontFamily -> "Helvetica", 14] &],
LabelingFunction -> Placed[{"17%", "33%", "50%"}, Center],
AspectRatio -> 2, ImageSize -> 100]
But it doesn't display any numbers:
Finally, this works:
(3)
BarChart[{{1, 2, 3}}, ChartLayout -> "Stacked", ChartLabels -> {
Placed[{Style[#, FontFamily -> "Helvetica", 10] & /@ {"17%", "33%",
"50%"},
Style[#, FontFamily -> "Helvetica", 14] & /@ {"aa", "bbb",
"cccc"}}, {Center, After}]},
AspectRatio -> 2, ImageSize -> 100]
Is the syntax in (1) and (2) incorrect, or are those bugs?
Also note that FontSize
doesn't match. If it is set to the same value for both numerical and text labels, the numerical values look larger. What's going on there?