# How to change the base of logarithmic-scale plots?

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?

-
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
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 Nov 11 '12 at 19:03
@RahulNarain: Please post this as an answer. – Brett Champion Nov 11 '12 at 23:58
@Brett: Done.${}$ – Rahul Nov 12 '12 at 4:02

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}]


-
Thank you very much :) – Jérémie Nov 11 '12 at 18:13

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}]


-