The code

Plot[Zeta[x], {x, 2, 20}, ScalingFunctions -> "Log"]

produces the following image, which is a plot of the Zeta function but the y-axis is not logarithmic.

Plot of Zeta-function

Replacing Zeta by a different function produces a logarithmic scaling on the y-axis.

The scaling function Log10 and Log2 also fail. LogPlot also fails.

I tested the code in 12.2 and 11.3, both fail.

Is this a bug or am I missing something? I'm hesitating to call this a bug (and report it to Wolfram), as this seems to be something which should have been encountered before.

  • 5
    $\begingroup$ Log scaling of the range $[1.00, 1.08]$ is going to appear nearly linear. $\endgroup$
    – Michael E2
    Jan 4 at 18:07
  • 2
    $\begingroup$ To convince yourself that the log scaling is happening, enlarge the ordinate range: Plot[Zeta[x], {x, 2, 20}, PlotRange -> {Automatic, {0.1, 10}}, ScalingFunctions -> "Log"]. $\endgroup$
    – MarcoB
    Jan 4 at 18:53
  • $\begingroup$ Ahh, you are both right. I knew this is not a bug and I am missing something. Thank you! $\endgroup$
    – A.Z.
    Jan 4 at 19:02

Maybe worth showing this: Verification of log scaling, although with a significant but small error in the first point:

plot = Plot[Zeta[x], {x, 2, 20}, ScalingFunctions -> "Log"];

{xvals, logzvals} = 
  Transpose@First@Cases[plot, Line[p_] :> p, Infinity];

Rest@Log@Zeta[xvals] == Rest@logzvals
(* True  *)

First@Log@Zeta[xvals] - First@logzvals
(*  -0.0000556227  *)

(Log scaling of the small range $[1.00,1.08]$ is going to appear nearly linear. In fact, any scaling by an analytic function over a small enough range will appear linear.)

  • 1
    $\begingroup$ Anyone have an explanation for the error in the first point? Seems too big not to be a bug, but it's small enough not to make a different to the picture. I go so far as to suggest a bug, since sometimes people use the output of Plot for numerical computations. (There's an error without the log scaling, too.) $\endgroup$
    – Michael E2
    Jan 4 at 18:28
  • 2
    $\begingroup$ It seems to be somehow linked with the automatically restricted plot range. Adding PlotRange -> All to the plot expression removes the error (i.e. your last expression evaluates to $0$). I don't understand why it happened in the first place though. $\endgroup$
    – MarcoB
    Jan 4 at 18:58
  • $\begingroup$ @MarcoB Thanks. It seems to happen with other functions and truncated plot ranges, with varying degrees of error. $\endgroup$
    – Michael E2
    Jan 4 at 19:11
  • $\begingroup$ @MarcoB Perhaps the endpoint of the truncated plot is done by simpliy cutting the first/last line segment (in effect, using linear interpolation). It would be simpler than solving y == f[x] for the boundary point. $\endgroup$
    – Michael E2
    Jan 4 at 19:44

This is not a bug. Just the scale is small enough to be noticed by the eye!

You can try this code, which is just your code added a more length of the y-axis :

Plot[Zeta[x], {x, 2, 20}, ScalingFunctions -> "Log", 
 PlotRange -> {{0, 20}, {0, 2}}]

Now the result is :


in which the logarithmic scale is more emphasized.


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