Most convenient way to set legend marker size?
I always do it like this:
cm = 72/2.54;
BarChart[{{1, 2, 3}, {1, 3, 2}},
ChartLegends -> SwatchLegend[{"a", "b", "c"}, LegendMarkerSize -> 20], ImageSize -> 4 cm]
top: code from your question, bottom: this code
The colors of the legend are inherited from the BarChart object:
BarChart[{{1, 2, 3}, {1, 3, 2}}, ChartStyle -> {Red, Green, Blue},
ChartLegends -> SwatchLegend[{"a", "b", "c"}, LegendMarkerSize -> 20], ImageSize -> 4 cm]
For ChartLegends
, although the documentation does not mention any values other than "Row"
and "Column"
for the option LegendAppearance
, it turns out you can also use this option to set the LegendMarkerSize
BarChart[{{1, 2, 3}, {1, 3, 2}}, ChartStyle -> {Red, Green, Blue},
LegendAppearance -> {LegendMarkerSize -> 20},
ChartLegends -> {"a", "b", "c"}, ImageSize -> 4 cm]
In fact, you can use any of the options for SwatchLegend
as the setting for LegendAppearance
:
Row[BarChart[{{1, 2, 3}, {1, 3, 2}}, ChartStyle -> {Red, Green, Blue},
ChartLegends -> {"a", "b", "c"}, ImageSize -> 4 cm,
LegendAppearance -> #] & /@ {
{LegendLabel -> "legend"},
{LabelStyle -> Red},
{LegendLayout -> "ReversedColumn", LegendMarkerSize -> 20},
{LegendLayout -> "ReversedRow", LegendMarkerSize -> 20,
LegendMarkers -> "Bubble"}}]
For PlotLegends
, this approach does not work.