Bug introduced in 10.0 and fixed in 10.4
In this post @Heike provides this code:
ticksfun[xmin_, xmax_] :=
Table[{10^i, Superscript[10, i]}, {i, Floor[Log10[xmin]],
Ceiling[Log10[xmax]]}]
LogLogPlot[Log[x!], {x, 1, 10^5},
PlotRange -> {{0, 10^5}, {10^-1, 10^6}},
Ticks -> {ticksfun, ticksfun}]
The error is:
Tick specification must be a list or a function
The help page for Ticks
looks identical in v10 and v9. So the main question, is this a bug or is there an undocumented change in v10?
Note: Ticks
in Plot
seems to work relatively ok in v10.
Update
Based on the analysis provided by @rcollyer, I did some tests between Mathematica v9 and v10:
minmax = {};
ticksfun[xmin_, xmax_] := Module[{i},
minmax = {xmin, xmax};
Table[{10^i, Superscript[10, i]},
{i, Floor[Log10[xmin]], Ceiling[Log10[xmax]]}]
];
minmax2 = {};
ticksfun2[xmin_, xmax_] := Module[{i},
minmax2 = {xmin, xmax};
Table[i, {i, Floor[xmin], Ceiling[xmax]}]
];
Then I run:
LogLogPlot[x^2, {x, 1, 10}, Ticks -> {ticksfun, ticksfun}]
Plot[x^2, {x, 1, 10}, Ticks -> {ticksfun2, ticksfun2}]
The first plot has error, the second is ok, fine, so what does Mathematica v9 return on minmax:
In[13]:= minmax
minmax2
Out[13]= {1., 100.}
Out[14]= {-2.08333, 102.083}
What does Mathematica v10.4 return on minmax?
In[101]:= minmax
minmax2
Out[101]= {-0.511686, 5.11686}
Out[102]= {-5.55556, 105.556}
I am not experienced in the internals of Mathematica but all this suggests that there is a change in what the plotting functions are sending to ticks fucntions. And notice the change is not only in LogLogPlot
but in Plot
as well.
I think Mathematica should not be passing negative numbers in LogLogPlot
.
Update 2
When I tried to implement the solution by @rcollyer, I realized, it is necessary to to further conversions. The solution posted at the bottom creates wrong descriptions of the axis --- the ticks are misplaced. The problem is that the range is supplied in natural logarithm while, we are placing log10 descriptions. At this moment I have something like:
ticksnofun[xmin_, xmax_] := Module[{i, xmine, xmaxe, xmin10, xmax10},
{xmine, xmaxe} = {xmin, xmax};
{xmin10, xmax10} = (#/Log[10]) & /@ {xmine, xmaxe};
{xmin10, xmax10} = {Ceiling[xmin10], Floor[xmax10]};
tcks10 = Table[i, {i, xmin10, xmax10}];
tckse = (#/Log10[E]) & /@ tcks10;
Transpose[{tckse, Superscript[10, #] & /@ tcks10}]
];
I am curious whether this could be written in a "better" Mathematica way (yet keeping it readable)?
Plot
doesn't work from either. $\endgroup$Plot
norLogLogPlot
. Posting answer now. $\endgroup$LogLogPlot
is now passing scaled values, i.e. they are theLog
of the range. There is a bug inLogLogPlot
in that a ticks function is not accepted at all between 10.0 and 10.3. That has been mostly fixed. $\endgroup$LogLogPlot
. $\endgroup$