7

Bug introduced in 11.3 and fixed in 12.0

I've noticed these small ruler-type markers at the bottom of BarLegend objects.

BarLegend["Rainbow"]

bar

(Enhance!)

zoomedbar

I don't remember seeing them in previous answers and they only appear in the documentation when I reevaluate objects. I don't see any reference to it in the documentation to manipulate or hide them either (I've tried Ticks->None to no effect). Any ideas how to remove them?

This is on Mathematica 11.3 on Linux.

Musang
  • 1,038
  • 1
  • 9
  • 20

2 Answers2

5

I get the same issue in version 11.3 (Wolfram Cloud):

$Version

"11.3.0 for Linux x86 (64-bit) (March 7, 2018)"

bl = BarLegend["Rainbow", LegendMarkerSize -> {100, 300}]

enter image description here

ImageResize[ImageCrop[Rasterize[bl, RasterSize -> 200], {Full, 100}, Top], 500]

enter image description here

This is caused by the option FrameTicks -> {{False, False}, {True, False}} (that gets in there somewhere along the way):

Cases[ToBoxes[bl], p : Rule[FrameTicks, _], Infinity] 

{FrameTicks -> {{False, False}, {True, False}}}

A work-around: post-process the box expression to modify FrameTicks option value:

RawBoxes @ Replace[ToBoxes[bl], Rule[FrameTicks, _] :> Rule[FrameTicks, False], ∞]

enter image description here

Alternatively, change the setting for FrameTicksStyle to White:

RawBoxes@Replace[ToBoxes[bl], Rule[FrameTicksStyle, _]:> Rule[FrameTicksStyle, White], ∞]

same picture

kglr
  • 394,356
  • 18
  • 477
  • 896
3

kglr's answer shows a more comprehensive analysis of what is going on. However, if the goal is to export your graphic, there's a simple, but limited workaround. Testing shows that using Export on a rasterized format will display the artefact ticks but NOT if the export is in vector graphics format.

Compare

Export["rasterbar.png",BarLegend["Rainbow"]]

and

Export["vectorbar.svg",BarLegend["Rainbow"]]

(*.pdf also works)

Musang
  • 1,038
  • 1
  • 9
  • 20