我有以下示例代码:
require(latticeExtra)
require(gridExtra)
require(ggplot2)
require(grid)
lay <- matrix(c(1,1,1,2), 1,4,byrow = FALSE)
z<-sort(rnorm(100))
x<- rep(seq(1,10), times=10)
y<-rep(seq(1,10), each=10)
p<- levelplot(z ~ x * y,
par.settings=list(axis.text=list(fontfamily="serif"),),
colorkey = list(labels=list(par.settings=list(fontfamily='serif'))))
leg.list <- p$legend$right$args$key
leg <- draw.colorkey(leg.list)
grid.arrange(grobs = list(p, leg), layout_matrix = lay)
我希望little colorkey(levelplot的一部分)中的标签字体与大colorkey中的标签字体相匹配(使用draw.colorkey()
制作)。我怎么能这样做?
非常感谢你的帮助!
答案 0 :(得分:1)
试试这个:
leg <- draw.colorkey(leg.list)
leg$children[[4]]$children[[1]]$gp$cex <- 0.75
grid.arrange(grobs = list(p, leg), layout_matrix = lay)
为两个颜色键设置相同的字体系列,我们得到了更好的结果:
leg <- draw.colorkey(leg.list)
leg$children[[4]]$children[[1]]$gp$cex <- 0.8
leg$children[[4]]$children[[1]]$gp$fontfamily <- "serif"
grid.arrange(grobs = list(p, leg), layout_matrix = lay)