# 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 ? Nov 11, 2012 at 17:14
• Yes, I guess :) Nov 11, 2012 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.
– user484
Nov 11, 2012 at 19:03
• @RahulNarain: Please post this as an answer. Nov 11, 2012 at 23:58
• @Brett: Done.${}$
– user484
Nov 12, 2012 at 4:02

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

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

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

ListPlot[data, Ticks -> {myTicks, Automatic}] 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}] 