Search code examples
rlevelplot

Adjust number of ticks in R levelplot


I have a following R code:

library(lattice)
x <- rep(seq(6,15,by=1), each=20)
y <- rep(seq(0,0.95,by=0.05), 10)
z <- x*y
levelplot(z ~ x * y)

It produces this plot: enter image description here

How can I have ticks at 6, 7, ..., 15 on x-axis and ticks at 0.0, 0.1, ..., 0.9 on y-axis?


Solution

  • library(lattice)
    x <- rep(seq(6,15,by=1), each=20)
    y <- rep(seq(0,0.95,by=0.05), 10)
    z <- x*y
    
    x.scale <- list(at=seq(6,15,1))
    y.scale <- list(at=seq(0,0.9,0.1))
    
    levelplot(z ~ x * y, scales=list(x=x.scale, y=y.scale))
    

    enter image description here