7
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ They are not there in 11.3 on Windows 8.1. $\endgroup$ – Johu Sep 4 '18 at 17:50
  • $\begingroup$ Also absent on my Windows 10 PC... $\endgroup$ – Musang Sep 4 '18 at 19:50
  • $\begingroup$ I've sent a bug report to Wolfram and they've reproduced and acknowledged the issue. I'll update this question if I further information comes around. $\endgroup$ – Musang Sep 6 '18 at 9:00
5
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.