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

孤街浪徒 提交于 2019-11-27 06:21:25

问题


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:


回答1:


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()



来源:https://stackoverflow.com/questions/24528527/how-to-add-a-title-to-legend-scale-using-levelplot-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!