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.

Mathematica provides a score of convenient functions to make plots with various logarithmic scale axes, for instance I am using ListLogLinearPlot to have a discrete plot with a logarithmic x-axis and a linear y-axis.

My issue however is that I would like the x-axis to be on a binary logarithmic scale, instead of the default logarithmic scale (natural? with decimal ticks?). In particular I need 2, 4, 8, 16, 32, etc. to be equally spaced on the x-axis to highlight the periodic nature of the function I'm plotting.

How may I proceed?

share|improve this question
1  
So all you want is defining your custom ticks ? –  b.gatessucks Nov 11 '12 at 17:14
    
Yes, I guess :) –  Jérémie Nov 11 '12 at 17:45
1  
To be clear, all logarithmic scales are just rescalings of each other, because $\log_a x = \ln x/\ln a$. In particular, 2, 4, 8, 16, 32, etc. are already equally spaced in any logarithmic scale: try LogLinearPlot[Cos[x], {x, 1, 16}, AxesOrigin -> {1, 0}, Ticks -> {{1, 2, 4, 8, 16}, Automatic}] and see. –  Rahul Narain Nov 11 '12 at 19:03
    
@RahulNarain: Please post this as an answer. –  Brett Champion Nov 11 '12 at 23:58
    
@Brett: Done.${}$ –  Rahul Narain Nov 12 '12 at 4:02
add comment

2 Answers 2

up vote 3 down vote accepted

You can use the normal ListPlot and scale/label your data :

data = Table[{Log[x]/Log[2], Cos[x]}, {x, Range[1, 16, 0.05]}];

myTicks = {Log[#]/Log[2], #} & /@ Range[1, 16];

ListPlot[data, Ticks -> {myTicks, Automatic}]

plot

share|improve this answer
    
Thank you very much :) –  Jérémie Nov 11 '12 at 18:13
add comment

By request:

You don't need a new kind of plot function for this. The existing logarithmic plots already do exactly what you want! It doesn't matter what the base of the logarithm is: all logarithmic scales are just rescalings of each other, because $$\log_a x = \frac{\ln x}{\ln a}$$ for any base $a$. In particular, 2, 4, 8, 16, 32, etc. are already equally spaced in any logarithmic scale. For example:

LogLinearPlot[Cos[x], {x, 1, 16}, AxesOrigin -> {1, 0}, Ticks -> {{1, 2, 4, 8, 16}, Automatic}]

enter image description here

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.