Apparently, BarLegend in version 10 displays tick legends in scientific notation when they are smaller in magnitude than 0.01. For instance,

BarLegend[{"Rainbow", {-.015, .015}}, 
LabelStyle -> Directive[Black, Bold, FontSize -> 12]]

creates the object

enter image description here

How can I change the tick labels to decimal notation, as they would have appeared in version 9?

By the way, the Bold directive evidently is being ignored. Is there a work-around for this?

  • 2
    $\begingroup$ Just had a look at examples in the docs and LabelStyle looks very buggy. You shouldn't need to explicitly use FontSize, the number should be sufficient -- but it is not. As you say Bold is not recognised, nor is FontWeight->Bold. $\endgroup$ – Mike Honeychurch Jul 17 '14 at 22:28
  • 1
    $\begingroup$ Seems to work OK in 10.0.1 $\endgroup$ – Sjoerd C. de Vries Sep 17 '14 at 13:51
  • $\begingroup$ @Sjoerd Confirmed. $\endgroup$ – Mr.Wizard Sep 17 '14 at 14:05

Two work-arounds:

(1) Use TickLabels

BarLegend[{"Rainbow", {-0.015, 0.015}}, ImageSize->300,
  Charting`TickLabels -> 
  (Style[NumberForm[#, {Infinity, 3}],Bold,Black,12] & /@ Range[-.015, .015, .005])]

enter image description here

(2) Use LabelingFunction:

BarLegend[{"Rainbow", {-0.015, 0.015}}, ImageSize->300, 
    LabelingFunction -> (Style[NumberForm[#, {Infinity,3}],Bold, Black,12] &)]
(* same picture *)

Note: Just to make the labels Bold the option combination BaseStyle->Directive[Bold,12], LabelStyle->Black also works.

  • $\begingroup$ Despite the fact that Mathematica flags ImageSize, BaseStyle, LabelingFunction, and Charting`TickLabels as unknown option names, both of your recommendations work well. Thanks, @kguler. $\endgroup$ – bbgodfrey Jul 18 '14 at 14:17
  • $\begingroup$ @bbgodfrey, thank you for the accept. $\endgroup$ – kglr Jul 18 '14 at 22:29
  • $\begingroup$ Version 10.0.1 appears to resolve the issues described above. $\endgroup$ – bbgodfrey Nov 16 '14 at 18:20

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.