# Custom y-axis Compression

Plotting a function in log-scale is a very common way to "compress" a function that grows too fast. What I want to do is to use a different function to compress a plot by. For example, I would like to scale the Y-Axis by a function I call the "bilateral logarithm" which is given by

BLog[x_] = Sign[x] Log2[Abs[x] + 1];


This function is nice because it is asymptotic to -Log2(-x) as x approaches -inf, Log2(x) as x approaches +inf, and BLog(-1)=-1, BLog(0)=0, BLog(1)=1. And all of this always holds for nested Blog(Blog(...)).

In summary, for a log-scale plot, the distances on the y-axis are proportional to Log(y), and I want to make it proportional to BLog(y). How do I make it happen?

edit: the inverse of this function is

Sign[x] (2^Abs[x] - 1)


\$Version

(* "13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)" *)

Clear["Global*"]

BLog[x_] = Sign[x] Log2[Abs[x] + 1];

Plot[BLog[x], {x, -5, 5}] The inverse is

ParametricPlot[{BLog[x], x}, {x, -5, 5}, AspectRatio -> GoldenRatio] Unfortunately, InverseFunction doesn't work well

Plot[InverseFunction[BLog][x], {x, -3, 3}] Solving for the inverses

Assuming[y > 0, SolveValues[{y == BLog[x], x >= 0}, x][] // Simplify]

(* -1 + 2^y *)

Assuming[y < 0, SolveValues[{y == BLog[x], x < 0}, x][] // Simplify]

(* 1 - 2^-y *)


Consequently, use

invBLog[x_] = -Sign[x] + Sign[x] 2^(x Sign[x]) // Simplify

(* (-1 + 2^(x Sign[x])) Sign[x] *)


EDIT:

invBLog[x_] = FullSimplify[invBLog[x], x ∈ Reals]

(* (-1 + 2^Abs[x]) Sign[x] *)


Comparing with ParametricPlot

Show[
ParametricPlot[{BLog[x], x}, {x, -5, 5}, AspectRatio -> GoldenRatio],
Plot[invBLog[x], {x, -3, 3}, PlotStyle -> Directive[Red, Dashed]]] An example of its use

Plot[x^3*Exp[x], {x, -10, 10}, Axes -> True,
ScalingFunctions -> {None, {BLog, invBLog}}] • Thanks. Turns out it is possible to invert BLog also using Sign[] function IBLog[x_]=Sign[x] (2^Abs[x] - 1). Why does ScalingFunctions -> {None, IBLog} not work? Why do I need to do {BLog,IBLog} ? Jul 23 at 1:15
• For a custom scaling function you have to provide both the scaling function and its inverse. See the documentation. Jul 23 at 1:48

You may use the parameter "ScalingFunctions". However, note that for this you need a function and its inverse. It will create some warning because the iinverse may be multivalued. However this is not the case for BLog. Here is an example. Without scaling function:

Plot[Exp[x], {x, 0, 10}] And with BLog scaling function:

BLog[x_] = (Log[1 + Abs[x]] Sign[x])/Log;
Plot[Exp[x], {x, 0, 10}, Axes -> true,
ScalingFunctions -> {None, {BLog, InverseFunction[BLog]}}]
` 