【问题标题】:levelplot multiplot with margins, without blank spaceslevelplot multiplot 有边距,没有空格
【发布时间】:2021-10-11 00:09:33
【问题描述】:

我在使用带边距的 levelplot 函数创建多图时遇到了困难。

每次尝试我都会遇到至少一个问题:太多的空白、错误或太大的边距。

library(raster)
library(rasterVis)
library(gridExtra)

f <- system.file("external/test.grd", package="raster")
r <- raster(f)
x <- levelplot(r, margin=T)


# ATTEMPT 1
print(x, split = c(1, 1, 2, 2), more = TRUE)
print(x, split = c(2, 1, 2, 2), more = TRUE)
print(x, split = c(1, 1, 1, 2), more = FALSE)

# ATTEMPT 2 - error

l <- rasterVis::levelplot(raster::stack(list(x, x, x)), layout=c(3,1), margin = T);  l

# ATTEMPT 3 = best, but a lot of white space and bigger margin

grobs <- arrangeGrob(grobs=list(x, x, x), ncol=3)
grid.arrange(grobs)

我想要这样的东西:(如果有 commom 传说,则奖励)

ty!

【问题讨论】:

    标签: r raster levelplot


    【解决方案1】:

    经过一番挖掘,您可以修改格子图的某些部分,例如R remove whitespace between levelplot grobs

    我已经在您的 x 对象上进行了尝试,它看起来更好。我添加了更多的边距,因为它们的默认值删除了图例文本,例如试试

    x <- levelplot(r, margin=TRUE)
    
    x$par.settings$layout.heights[
      c( 'bottom.padding',
         'top.padding',
         'key.sub.padding',
         'axis.xlab.padding',
         'key.axis.padding',
         'main.key.padding') ] <- 1
    x$aspect.fill <- TRUE
    
    grobs <- arrangeGrob(grobs=list(x, x, x), ncol=3)
    grid.arrange(grobs)
    

    【讨论】:

      猜你喜欢
      • 2013-12-27
      • 2021-08-27
      • 1970-01-01
      • 2014-01-17
      • 1970-01-01
      • 2010-11-17
      • 2016-08-22
      • 1970-01-01
      • 2018-04-16
      相关资源
      最近更新 更多