The R
graphics
package has the function axTicks
that returns the tick locations of the ticks that the axis
and plot
functions would set automatically. The other answers given to this question define the tick locations manually which might not be convenient in some situations.
myTicks = axTicks(1)
axis(1, at = myTicks, labels = formatC(myTicks, format = 'd'))
A minimal example would be
plot(10^(0:10), 0:10, log = 'x', xaxt = 'n')
myTicks = axTicks(1)
axis(1, at = myTicks, labels = formatC(myTicks, format = 'd'))
There is also an log
parameter in the axTicks
function but in this situation it does not need to be set to get the proper logarithmic axis tick location.