Search code examples
rlevelplot

Change font in colorkey legend in R levelplot


I have the next plot with increased ticks and axis label font size:

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,
          scales=list(x=list(at=seq(6,15,1), cex=2), y=list(at=seq(0,0.9,0.1), cex=2)),
          xlab=list(label="x", cex=2),
          ylab=list(label="y", cex=2))

But how can I increase the font size in the colorkey legend as well? enter image description here


Solution

  • Use argument colorkey in levelplot:

    library(lattice)
    x <- rep(seq(6,15,by=1), each=20)
    y <- rep(seq(0,0.95,by=0.05), 10)
    z <- x*y
    
    ckey <- list(labels=list(cex=2))
    
    levelplot(z ~ x * y,
          scales=list(x=list(at=seq(6,15,1), cex=2), y=list(at=seq(0,0.9,0.1), cex=2)),
          xlab=list(label="x", cex=2),
          ylab=list(label="y", cex=2), 
          colorkey=ckey)
    

    enter image description here