[R] minor axis ticks in trellis graphics?
ehlers at ucalgary.ca
Sat Jul 28 23:31:23 CEST 2012
Mea culpa! I screwed up. I was answering (not well, at that) a
different question and somehow managed to make it a response to
Here's what may be a solution to your problem.
(see also this post by ilai:
We define appropriate locations for the x-ticks to go with
suitably defined labels and corresponding tick lengths.
d <- data.frame(x = 1:11, y = rnorm(11))
## Where to put ticks and labels
myat <- 1:11
mylab <- head(c(rbind(LETTERS[1:6], "")), -1)
# putting letters at every second tick
## lengths of ticks
mytck <- head(c(rbind(rep(1,6), .5)), -1)
## myat, mylab, mytck should all be same length
xyplot(y ~ x, data = d, xlab="",
scales = list(x = list(
at = myat, labels = mylab)),
par.settings = list(
axis.components = list(
bottom = list(tck = mytck))))
## Try it with different myat etc to see how it works
myat <- seq(1, 11, by = 2/3)
mylab <- head(c(rbind(LETTERS[1:6], "", "")), -2)
mytck <- head(c(rbind(rep(2,6), .5, .5)), -2)
myat <- seq(1, 11, by = 1/2)
mylab <- head(c(rbind(LETTERS[1:6], "", "", "")), -3)
mytck <- head(c(rbind(rep(2,6), .5, 1, .5)), -3)
The trick is in constructing suitable vectors myat, mylab,
and mytck which you can do any way you like but I would
check that the lengths are equal (recycling works fine
for simple cases but always seems to trip me up in more
On 2012-07-26 07:02, Martin Ivanov wrote:
> Dear Peter,
> Thank You very much for your suggestion. However, it seems to me to make a completely new notation to the x axis. While I just need to add minor ticks to the axis, that is smaller ticks inbetween the basic ticks.
> The other option would be to say which ticks to be small and which big, but I have no idea how.
> Any suggestions will be appreciated.
> Best regards,
<< embarassing junk from P. Ehlers cut >>
More information about the R-help