Although there are hidden options to the underlying function (Charting`iBarLegend
) that seem to address the required functionality, there does not seem to be any way to get the user-exposed function BarLegend
to react to them. The following did not change the presentation of the test cases you provided, and neither did attempts to pass some promising-sounding options directly through BarLegend
. For example the following did not change anything:
BarLegend["LakeColors", 12, "SmoothRange" -> False]
I suspect that there is no way to get the desired effect in current versions of Mathematica using straightforward options, though I could be wrong. And as Karsten's excellent answer shows, it is possible to force the issue by constructing the raster manually.
SetOptions[Charting`iBarLegend, ShowContours -> True]
{ColorFunctionScaling -> Automatic, ImageSize -> Automatic,
ImageSizeAction -> Automatic, RoundingRadius -> Automatic,
FrameStyle -> Automatic, Alignment -> Automatic,
Spacings -> Automatic, Scrollbars -> False, ScrollPosition -> {0, 0},
Background -> Automatic, ContentPadding -> True,
DefaultLabelStyle -> {}, "Orientation" -> "Column",
Charting`AxesLabelRotate -> True, Charting`AxisAnnotation -> None,
Charting`AxisFactor -> None, Charting`AxisAppearance -> Automatic,
Charting`AxisLabel -> None, Charting`LabelSide -> Automatic,
Charting`PadLabels -> Automatic, Charting`RotateLabels -> False,
Charting`TickAnnotations -> None, Charting`TickSide -> Automatic,
Charting`TickLabels -> Automatic, Charting`TickLengths -> Automatic,
Charting`TickMarkers -> Automatic, Charting`TickWrappers -> None,
Charting`RotateTicks -> 0, AxesLabel -> None, AxesStyle -> Automatic,
Frame -> True, FrameStyle -> Automatic,
LabelingFunction -> Automatic, Ticks -> Automatic,
TicksStyle -> Automatic, AspectRatio -> Automatic,
ScalingFunctions -> {Identity, Identity}, BaseStyle -> {},
"LegendMethod" -> "Fixed", "Density" -> "Continuous",
"SmoothRange" -> True, "AxesPriority" -> Automatic,
"Sorting" -> True, "ContourMethod" -> "Graphics",
"RenderMode" -> Automatic, "LegendItemLayout" -> Automatic,
"PinningPoint" -> None, "StyledContours" -> None,
"ShowContours" -> True, PlotTheme -> "Mathematica"}