# [R] minor axis ticks in trellis graphics?

Peter Ehlers ehlers at ucalgary.ca
Sat Jul 28 23:31:23 CEST 2012

```Dear Martin,

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.
<<https://stat.ethz.ch/pipermail/r-help/attachments/20120718/7133b673/attachment.pl>>)

We define appropriate locations for the x-ticks to go with
suitably defined labels and corresponding tick lengths.

## data:
d <- data.frame(x = 1:11, y = rnorm(11))

## Where to put ticks and labels
myat  <- 1:11
# putting letters at every second tick

## lengths of ticks

## myat, mylab, mytck should all be same length

## plot
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
complicated cases).

Peter Ehlers

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,
>
> Martin
>

<< embarassing junk from P. Ehlers cut >>

```