9
$\begingroup$

I found several topics about undocumented ScaledTicks function and tried to use this. Here is the first example:

g1 = Plot[Sin[3 x] Exp[-x], {x, 0, 10}, PlotRange -> All];
g2 = Plot[Sin[3 x] Exp[1.1 x], {x, 0, 10}, PlotRange -> All];
{pr1, pr2} = (PlotRange[#][[2]] & /@ {g1, g2});
Show[{g1, g2 /. Line[x_] :> 
 Line[({#[[1]], Rescale[#[[2]], pr2, pr1]} &) /@ x]}, 
 Axes -> False, Frame -> True, 
 FrameTicks -> {{Charting`ScaledTicks["Linear"], 
   Charting`ScaledTicks[{Rescale[#, pr2, pr1] &, Rescale[#, pr1, pr2] &}]},
   {Charting`ScaledTicks["Linear"], Automatic}}]

This gives a mess of second y-axis ticks:

enter image description here

But if we use "full" form of ScaledTicks:

Charting`ScaledTicks["Linear", {Rescale[#, pr2, pr1] &, Rescale[#, pr1, pr2] &}, "Nice"]

we see very nice picture:

enter image description here

So, the first question: should we always use "full" form of ScaledTicks even if there is no transformation of coordinates?

The second example is about LogPlot and similar functions.

Show[{LogPlot[x, {x, 1, 100}], Plot[x Log[100]/100, {x, 1, 100}]}, 
Axes -> False, Frame -> True, 
FrameTicks -> {{Charting`ScaledTicks["Log"], 
Charting`ScaledTicks["Linear", {#/100 Log[100] &, # 100/Log[100] &}, 
"Nice"]}, {Automatic, Automatic}}]

and the result:

enter image description here

Here for this simple case I make all rescaling "by hand". If we change ScaledTicks to its "short" form

Charting`ScaledTicks[{#/100 Log[100] &, # 100/Log[100] &}]

the picture will be the same. So, in this example "short" and "full" forms of ScaledTicks are equivalent. How can we explain the difference between examples?

And the final observation. Any change from the simplest form ScaledTicks["Log"] gives errors, i.e. we can't write even ScaledTicks["Log",{#&, #&},"Nice"].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.