Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When using ListLogLinearPlot the abscissa labels every other decade.

Is there a way to tell Mathematica to label each decade?

I need to use this inside Manipulate where the axes will scale according to the chosen variable.

enter image description here

Here is some example code of the kind I am using:

s[x_] := (10^-9) x^2; t[x_] := (10^-3) x^2; 
Manipulate[ ListLogLinearPlot[{ Table[{a s[T], T}, {T, 0, 1000}], 
 Table[{a t[T], T}, {T, 0, 1000}] }, 
 GridLines -> None, PlotStyle -> {Thickness[0.005]}, Joined -> True, 
 PlotRange -> Automatic], {a, 10^-8, 10^8}]
share|improve this question
    
Could you please give an example of code - best the one producing this graphics, or your manipulate. –  Vitaliy Kaurov Mar 30 '12 at 20:04
2  
Perhaps this could help, see CustomTicksGuide.pdf, p. 4. –  partial81 Mar 30 '12 at 20:40
    
@VitaliyKaurov s[x_] := (10^-9) x^2; t[x_] := (10^-3) x^2; Manipulate[ ListLogLinearPlot[{ Table[{a s[T], T}, {T, 0, 1000}], Table[{a t[T], T}, {T, 0, 1000}] }, GridLines -> None, PlotStyle -> {Thickness[0.005]}, Joined -> True, PlotRange -> Automatic], {a, 10^-8, 10^8}] –  CaptanFunkyFresh Mar 30 '12 at 21:29
add comment

migrated from stackoverflow.com Mar 30 '12 at 18:56

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 9 down vote accepted

You can create some custom ticks that work the way you want. There might be a better way than Superscript, but I couldn't work out how to get ScientificForm or NumberForm to just show the exponent rather than 1 x 10^4 etc.

myTicks = Table[{10^i, Superscript[10, i]}, {i, -20, 15}]

Notice I've changed the way the a variable enters into the Manipulate, as it will give you more chance to explore some of the lower-exponent values.

Manipulate[
 ListLogLinearPlot[{Table[{10^a s[T], T}, {T, 0, 1000}], 
   Table[{10^a t[T], T}, {T, 0, 1000}]}, GridLines -> None, 
  Ticks -> {myTicks, Automatic}, PlotStyle -> {Thickness[0.005]}, 
  Joined -> True, PlotRange -> Automatic], {a, -8, 8}]

enter image description here

share|improve this answer
    
ListLogLinearPlot[] uses Superscript[] too ... so it seems the way to go. –  belisarius Mar 31 '12 at 15:35
    
Thanks @Verbeia, this works just fine. I am now trying to implement this into FrameTicks where the upper horizontal tick marks are shown but without the decade labels, but this isn't a major concern. –  CaptanFunkyFresh Apr 2 '12 at 14:50
add comment

One can adapt this answer to a smilar question to define a number format as follows:

 exponentForm[num_?NumericQ] := 
 ToString@NumberForm[N@#1, ExponentFunction -> (# &), NumberFormat -> (#3 &)] &@num

Applied to a portion of Verbeia'a tick list, this function gives

enter image description here

You can use it to define custom ticks with exponent labels:

  myExpTicks = Table[{10^i, exponentForm[10^i]}, {i, -20, 15}];

And, finally use it in your Manipulate as

 Manipulate[
 ListLogLinearPlot[{Table[{10^a s[T], T}, {T, 0, 1000}], 
 Table[{10^a t[T], T}, {T, 0, 1000}]}, GridLines -> None, 
 Ticks -> {myExpTicks, Automatic}, PlotStyle -> {Thickness[0.005]}, 
 Joined -> True, PlotRange -> Automatic], {a, -8, 8}]

to get

enter image description here

share|improve this answer
add comment

You can create custom ticks and use ListPlot :

myTicks[lower_, upper_, step_] := Flatten[Module[{Local = #, LocalTicks}, 
 LocalTicks = Log[10, Range[10^(# - 1), 10^#, (10^# - 10^(# - 1))/(10 - 1)]]; 
 Join[{#, ""} & /@ Most[LocalTicks], {{Last[LocalTicks], Power[10, 
 ToString[Last[LocalTicks]]] }}]] & /@ Range[lower, upper, step], 1]

Manipulate[ListPlot[{Table[{Log[10, a s[T]], T}, {T, 0, 1000}], Table[{Log[10, 
 a t[T]], T}, {T, 0, 1000}]}, GridLines -> None, PlotStyle -> {Thickness[0.005]}, 
 Joined -> True, PlotRange -> Automatic, Ticks -> {myTicks[lower, upper, step],
  Automatic}, AxesOrigin -> {lower, 0}], {{lower, -20, "lower"}},
  {{upper, 10, "upper"}}, {{step, 1, "step"}}, Delimiter, {a, 10^-8, 10^8}]

customTicks

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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