BarLegend
leaves a white region at the other end of the legend (the "0 end"), which is best seen by plotting a frame around the legend:
BarLegend["Rainbow", LegendFunction -> "Frame"]
BarLegend["Rainbow", LegendFunction -> "Frame", LegendLayout -> "Row"]
This behaviour causes that the LegendLabel
is not centered with respect to the color bar (in the following plots, the label is not at the 0.5 tick). It appears that the label is centered with respect to the whole legend, which includes the white region, even when the frame is not plotted:
BarLegend["Rainbow", LegendLabel -> Placed["1", Right]]
BarLegend["Rainbow", LegendLabel -> Placed["1", Right], LegendFunction -> "Frame"]
BarLegend["Rainbow", LegendLabel -> "1", LegendLayout -> "Row"]
BarLegend["Rainbow", LegendLabel -> "1", LegendLayout -> "Row", LegendFunction -> "Frame"]
How can I place the LegendLabel
so that it appears centered with respect to the color bar (both in horizontal and vertical BarLegend
s)?
When the option LegendLayout->"Row"
is used, a possibility is to leave some white space before the label, but this is far from ideal:
BarLegend["Rainbow", LegendLabel -> " 1", LegendLayout -> "Row"]