4
$\begingroup$

I recently noticed that the Plot function has a new embeded scaling function SignedLog, which looks like the matplotlib symlog. The implementation of symlog-like function is discussed a lot in this forum, such as symlog-like-plot-with-a-mixed-log-linear-log-scale, how-to-get-negative-values-of-function-on-y-axis-when-i-am-plotting-as-logplot. Now that Mathematica has its own implementation, I would like to know exactly what function it used.

On a side note, there seems to be some bugs when Around and IntervalMarkers->"Fences" (or "Bars") are used along with this.

Edit:
I figured it out just after I posted this question. So see details in the answer below. Any other thoughts on this topic is welcomed.

$\endgroup$
1
  • $\begingroup$ Oh heck yeah. Thanks for finding this! $\endgroup$
    – evanb
    Commented Feb 15, 2022 at 21:56

1 Answer 1

7
$\begingroup$

My guess is it's not symlog described in the first post:

symlog = {Function[x, Sign[x] (Log[Abs[x] + 1])], 
  Function[y, Sign[y] (Exp[Abs[y]] - 1)]};

I tested it with the following example:

Show[Plot[x, {x, -10, 10}, ScalingFunctions -> "SignedLog", 
 PlotLabels -> "SignedLog"], 
 Plot[x, {x, -10, 10}, ScalingFunctions -> symlog, 
 PlotStyle -> Orange, PlotLabels -> "symlog"], PlotRange -> All]

enter image description here

Although it looks like

symlog10 = {Function[x, Sign[x] (Log10[Abs[x] + 1])], 
  Function[y, Sign[y] (10^Abs[y] - 1)]};

enter image description here

The manual also indicated another use (ScalingFunctions -> {"SignedLog", a}):

Show[Plot[x, {x, -10, 10}, ScalingFunctions -> {"SignedLog", 1/100}, 
  PlotLabels -> "{SignedLog,1/100}"], 
 Plot[x, {x, -10, 10}, ScalingFunctions -> symlog10, 
  PlotStyle -> {Dashed, Orange}, PlotLabels -> "symlog10"], 
 PlotRange -> All]

enter image description here

Seems like the scaled symlog works:

symlog10a[a_] := {Function[x, Sign[x] (Log10[Abs[x]/a + 1])], 
  Function[y, Sign[y] (10^Abs[y] - 1) a]};

Show[Plot[x, {x, -10, 10}, ScalingFunctions -> {"SignedLog",                 
  1/100}, 
    PlotLabels -> "{SignedLog,1/100}"], 
   Plot[x, {x, -10, 10}, ScalingFunctions -> "SignedLog", 
      PlotLabels -> "{SignedLog}"], 
     Plot[x, {x, -10, 10}, ScalingFunctions -> symlog10a[1/100], 
      PlotStyle -> {Dashed, Orange}, PlotLabels -> "symlog10"], 
     PlotRange -> All]

enter image description here

EDIT: Looks like there is a Floor function in SignedLog. The corresponding symlog10 should be:

symlog10aFloor[a_] := With[{aa=10^Floor@Log10@a},{Function[x, Sign[x] 
  (Log10[Abs[x]/aa + 1])], 
  Function[y, Sign[y] (10^Abs[y] - 1) aa]}];

Show[Plot[x, {x, -10, 10}, ScalingFunctions -> {"SignedLog",     7/100}, 
  PlotLabels -> "{SignedLog,7/100}"], 
 Plot[x, {x, -10, 10}, ScalingFunctions -> "SignedLog", 
  PlotLabels -> "{SignedLog}"], 
 Plot[x, {x, -10, 10}, ScalingFunctions -> symlog10aFloor[7/100], 
  PlotStyle -> {Dashed, Orange}, PlotLabels -> "symlog10Floor"], 
 Plot[x, {x, -10, 10}, ScalingFunctions -> symlog10a[5/100], 
  PlotStyle -> {Red}, PlotLabels -> "symlog10_old"], PlotRange -> All]

such that

enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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