I have bar with log scale:
BarLegend[{(Blend[{{Log10@1, White}, {Log10@10, Cyan}, {Log10@100,
Blue}}, Log10@#] &), {1, 100}}, Ticks -> {1, 10, 100}]
with result
How to get log-scale on the bar?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityThe difficulty here is that there are two different spaces you are working in and you have to know where each is being used. Specifically, we want the ticks in $\log_{10}$ space, but the labels in linear space. So, we have to specify the labels, too, to make it work correctly, e.g.
logTicks[min_, max_] := {#, 10^#} & /@ FindDivisions[{min, max}, 5]
Unfortunately, Ticks
does not accept a function in BarLegend
, otherwise I would do this
BarLegend[{"Rainbow", {0, 5}}, Ticks -> logTicks]
Instead, the range needs to be specified
BarLegend[{"Rainbow", {0, 5}}, Ticks -> logTicks[0,5]]
Options@BarLegend
, you'll notice Ticks
is not in the list. The FE at some point (can't remember exactly when) started marking unknown options red, even if they fell into a hidden list. So, treat the red as just a warning.
$\endgroup$
BarLegend[
{
{White, Cyan, Blue},
{0, Power[10, 6]}
}
, Power[10, Range[0, 5]]
]