       Logscale Tick Function

• To: mathgroup at smc.vnet.net
• Subject: [mg100005] Logscale Tick Function
• From: "M.Roellig" <markus.roellig at googlemail.com>
• Date: Thu, 21 May 2009 00:16:44 -0400 (EDT)

```Hi group,

I am somewhat unsatisfied with the default Tick function for LogPlots,
especially when it comes to preparing plots for publications, so I
tried come up with a custom tick function. Maybe it is useful to
somebody else.  I would appreciate any comments on the function.

logtic[min_, max_] := Module[{up, bot, steps, major, minor,
maxlabels},
bot = Floor[Log10@min];
up = Ceiling[Log10@max];
maxlabels = 13;
(* max labels visible per axis *)
If[up - bot > 10, steps = Ceiling[(up - bot)/maxlabels], steps = 1];
major =
Table[{10^(i) // N,
If[i =!= 0, DisplayForm[SuperscriptBox[10, i]], 1], {0.00625`,
0.`}, {GrayLevel[0.`], AbsoluteThickness[0.25`]}}, {i, bot, up,
steps}];
Which[up - bot <= 10,
minor =
Flatten[Table[{d*10^(i), "", {0.00375`, 0.`}}, {i, bot, up}, {d,
2, 9}] // N, 1],
up - bot <= 20,
minor =
Join[Table[{10^(i) // N,
"", {0.00625`, 0.`}, {GrayLevel[0.`],
AbsoluteThickness[0.25`]}}, {i, bot + 1, up, steps}],
Flatten[Table[{d*10^(i), "", {0.00375`, 0.`}}, {i, bot, up}, {d,
2, 9}] // N, 1]],
True,
minor =
Flatten[Table[{d*10^(i), "", {0.00375`, 0.`}}, {i, bot, up}, {d,
1, 1}] // N, 1]];
Flatten[Join[{minor}, {major}], 1]]

(* Examples *)

LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> tic]
LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> tic]
LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> tic]

(* compare this with the automatic behavior, which is not very
reasonable I think *)
LogLogPlot[x, {x, 10^-3, 10^15}]

Cheers,

Markus

P.S. Maybe my glasses are not as good as they used to be, but it looks
like Mathematica renders some of the subticks longer than the others.
The EPS output looks fine though. Did anybody else notice this?

```

• Prev by Date: Re: Wolfram|Alpha Lookup Tool for Mathematica
• Next by Date: Re: Re: Wolfram|Alpha Lookup Tool for Mathematica
• Previous by thread: Re: Solving integral equations numerically
• Next by thread: Re: Logscale Tick Function