hyat
hyat

Reputation: 1057

How to add a title to legend scale using levelplot in R?

I would like to add a title to my legend for this plot:

     library(lattice)
     x = 1:10
     y = rep(x,rep(10,10))
     x = rep(x,rep(10))
     z = x+y  
     levelplot(z~x*y,  
               colorkey = list(labels = list(cex=1,font=2,col="brown"), height=1, width=1.4),
               main = list('b',side=1,line=0.5))

Which produces:

enter image description here

Upvotes: 4

Views: 7166

Answers (1)

user3710546
user3710546

Reputation:

library(lattice)
library(grid)
x = 1:10
y = rep(x,rep(10,10))
x = rep(x,rep(10))
z = x+y  
levelplot(z~x*y, colorkey=list(labels=list(cex=1,font=2,col="brown"),height=1,width=1.4),main=list('b',side=1,line=0.5))
trellis.focus("legend", side="right", clipp.off=TRUE, highlight=FALSE)
grid.text(expression(m^3/m^3), 0.2, 0, hjust=0.5, vjust=1)
trellis.unfocus()

enter image description here

Upvotes: 9

Related Questions