Changing the width of BarLegend with Contour argument

Bug introduced in 10.0.2 or ealier and persisting through 11.0.1 or later

Is it possible to change the aspect ratio of the BarLegend in Mathematica?

The option LegendMarkerSize, in my case below, only changes the overall length of the bar.

So, for the example image below, how can I make the colour bar wider? Note that because of the contours argument, using LegendMarkerSize -> {300, 300} has no effect.

BarLegend[{“Rainbow”, {0.0, 1.0}}, 20, LegendMarkerSize -> 300,
LegendLabel -> Style[“Intensity”, Bold, FontSize -> 14],
LabelingFunction -> (Style[NumberForm[#, {Infinity, 1}],
FontSize -> 12] &)]



1 Answer


If you look under the documentation for LegendMarkerSize, you will see it accepts values of the form: {w, h}. So, you can specify the width, for example

BarLegend[“Rainbow”, LegendMarkerSize -> {100, 100}]



Doesn’t work with the OP’s case: Seems like a bug to me.
– Öskå
Nov 4 ’14 at 13:56



@Öskå its the contours (2nd argument) that is doing it. Reporting it.
– rcollyer
Nov 4 ’14 at 14:05



I figured it was the second argument indeed, thanks for reporting it.
– Öskå
Nov 4 ’14 at 14:06



Yes, sorry, meant to clarify but got called away – I did try these options but couldn’t get it to work. Thanks!
– blochwave
Nov 4 ’14 at 16:37