Search code examples
rmapsrasteraxis-labelslevelplot

Turn on x-axis and y-axis values when printing several rasters leveplot R


I would like to turn on the x and y-axis values (i.e. label the empty tick marks) in the following example:

library(rasterVis)
s <- stack(replicate(6, raster(matrix(runif(100), 10))))
levelplot(s, layout=c(3, 2), index.cond=list(c(1, 3, 5, 2, 4, 6)))

In the actual data, I will be labelling the empty tickmarks using lat and lon.

Thanks for your help.


Solution

  • library(rasterVis)
    s <- stack(replicate(6, raster(matrix(runif(100), 10))))
    
    x.scale <- list(font=10,
                    fontface=2,
                    alternating=1)
    
    y.scale <- list(font=10,
                    fontface=2,
                    alternating=1)
    
    levelplot(s, layout=c(3, 2), index.cond=list(c(1, 3, 5, 2, 4, 6)),
      scales = list(x=x.scale, y=y.scale))
    

    enter image description here