For fine control of the axes, plot them separately, so first suppress the axes by using argument axes = FALSE
in the plot()
call:
plot(x, y, type="h", log="xy", axes = FALSE)
Then add the axes as you want them
axis(side = 1, at = (locs <- 1/c(1,10,100,1000)), labels = locs)
axis(side = 2)
box()
Question 2 can be answered in the same way, you just need to specify the locations for the tick marks, perhaps setting argument argument tcl
in the axis()
call to be a bit smaller than default (which is -0.5
). The tricky bit is in generating the minor ticks you want. I could only come up with this:
foo <- function(i, x, by) seq(x[i,1], x[i, 2], by = by[i])
locs2 <- unlist(lapply(seq_along(locs[-1]), FUN = foo,
x= embed(locs, 2), by = abs(diff(locs)) / 9))
or
locs2 <- c(outer(1:10, c(10, 100, 1000), "/"))
which both give:
R> locs2
[1] 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000 0.010 0.020
[13] 0.030 0.040 0.050 0.060 0.070 0.080 0.090 0.100 0.001 0.002 0.003 0.004
[25] 0.005 0.006 0.007 0.008 0.009 0.010
We use them via another call to axis()
:
axis(side = 1, at = locs2, labels = NA, tcl = -0.2)
We suppress labels here using labels = NA
. You just need to work out how to do the vectors for at
...
Putting the two steps together we have:
plot(x, y, type="h", log="xy", axes = FALSE)
axis(side = 1, at = (locs <- 1/c(1,10,100,1000)), labels = locs)
axis(side = 1, at = locs2, labels = NA, tcl = -0.3)
axis(side = 2)
box()
Which produces:

As for question 3, what do you mean the maximum range? You can set the limits on the y-axis using the ylim
argument to plot()
. You provide the limits (min and max) like so
plot(x, y, type="h", log="xy", axes = FALSE, ylim = c(0.2, 1))
axis(side = 1, at = (locs <- 1/c(1,10,100,1000)), labels = locs)
axis(side = 2)
box()
But a range on it's own is not sufficient to define the limits, you'd need to tell us one of the min or max values to show on the plot or the actual range of values you want.