Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Frameticks and ListLogLinearPlot

402 views
Skip to first unread message

Luigi B

unread,
Jan 4, 2012, 5:09:59 AM1/4/12
to
Dear all,
I have the problem of adding ticks to a ListLogLinearPlot.
I use the code:

data = {{10^(-6), 72}, {10^(-5), 60}, {10^(-4), 45}, {10^(-3),
31}, {10^(-2), 33}, {10^(-1), 32}};


ListLogLinearPlot[data, Frame -> True,
FrameTicks -> {Table[{10^-n,
ScientificForm[1.*10^(-n), NumberFormat -> (10^#3&)]}, {n,
-1,6}],
Automatic, Automatic, None}, PlotRange -> {0, 100}]


this works well as long as the mantissa of the tick is different than
0. However, when this happens it does not work any more.

Could you pls help me out? Or suggest another code to do the same?

Thanks, Luigi

Scot T. Martin

unread,
Jan 5, 2012, 5:56:30 AM1/5/12
to
Luigi, some things that you think should be simple are in fact hard in Mathematica. Below is an example you can adapt to your own problem. This code would be called with an example like: FrameTicks -> {tickFunction[0, 500, "Style" -> Integer], tickFunction[0, 6, "Style" -> Decimal], {}, {}}:

In[1]:= Options[tickFunction] = {"Style" -> Automatic}

Out[1]= {"Style" -> Automatic}

In[2]:= Options[tickLabelStyleFunction] = {"Style" -> Automatic}

Out[2]= {"Style" -> Automatic}

In[3]:= tickLabelStyleFunction[value : _, opts : OptionsPattern[]] :=


Switch[
OptionValue["Style"],

Automatic,
value,

Integer,
IntegerPart[value],

Decimal,
NumberForm[value, {2, 1}]
]

In[4]:= tickFunction[start : _, stop : _, opts : OptionsPattern[]] :=


Map[

Function[
value,
{value,
tickLabelStyleFunction[value,
FilterRules[{opts}, Options[tickLabelStyleFunction]]],
{0, 0.02},
{Directive[Thickness[0.005]]}
}
],

N@FindDivisions[{start, stop}, 5]
]



________________________________________
From: Luigi B [l.ba...@gmail.com]
Sent: Wednesday, January 04, 2012 05:06
Subject: Frameticks and ListLogLinearPlot

Gabriel Landi

unread,
Jan 5, 2012, 6:02:08 AM1/5/12
to
I recommend the CustomTicks package.
http://library.wolfram.com/infocenter/Demos/5599/

It's awesome. For me it is almost a part of Mathematica.
However, it uses not the ListLogLinearPlot but only ListPlot. The PDF explain how to change your data to appear logarithmically in both the x and y axes.

To generate logarithmic meshes I use the following functions (practically "copied" from another system)

linspace[d1_, d2_, n_: 100] := N[d1 + (d2 - d1)/(n - 1) Range[0, n - 1]];
logspace[d1_, d2_, n_: 100] := 10^linspace[d1, d2, n];


Best Regards,

Gabriel=

Szabolcs Horvát

unread,
Jan 5, 2012, 6:03:09 AM1/5/12
to
Hi Luigi,

To show 10^0 verbatim, a workaround is using Superscript[]

Table[{10^-n, Superscript[10, -n]}, {n, -1, 6}]

Please see several alternative solutions here:

http://stackoverflow.com/questions/7860400/exponential-form-of-tick-marks-for-log-plot-in-mathematica

--
Szabolcs Horvát
Mma QA site proposal: http://area51.stackexchange.com/proposals/37304

0 new messages