# How to force FrameTicks labels to be nonlinear?

I want to make a color bar with nonlinear scale , with code

DensityPlot[v, {u, 0, 1}, {v, 1, 5}, ColorFunctionScaling -> False, ColorFunction -> (Blend[{{1, Red}, {2, Green}, {3, Blue}, {4, Yellow}, {5, Orange}}, #] &), AspectRatio -> 10, Frame -> True, PlotRangePadding -> 0, ImagePadding -> 25, FrameTicks -> {None, Automatic}, FrameLabel -> None]


I get the result

How to replace 1, 2, 3, 4, 5 labels with other labels e.g. 3, 9, 27, 81, 243?

• Have you tried Ticks option? Commented Apr 26, 2019 at 11:50

### Manual FrameTicks solution

In your specific example an easy way you can get the desired result by specifying the FrameTicks manually like this:

FrameTicks -> {{{{1, 3}, {2, 9}, {3, 27}, {4, 81}, {5, 243}}, None}, {None, None}}


### ScalingFunction with automatic FrameTicks solution

If the coordinate value to screen mapping you want to show itself is not linear, starting with V12 you can also use ScalingFunction in most plot functions. In your example you could e.g. do it like this:

DensityPlot[v, {u, 0, 1}, {v, 3, 243},
ColorFunctionScaling -> False,
ColorFunction -> (Blend[{{1, Red}, {2, Green}, {3, Blue}, {4, Yellow}, {5, Orange}}, Log[3, #]] &),
AspectRatio -> 10, Frame -> True, PlotRangePadding -> 0, ImagePadding -> 25, FrameLabel -> None,
ScalingFunctions -> {None, {Log[3, #] &, 3^# &}},
FrameTicks -> {{Automatic, None}, {None, None}}
]


Notice that we didn't have to manually specify the FrameTicks, they were generated for us, and that the ColorFunction now needs to be nonlinear, too.