levelplot:如何在colorkey和x-axis标签之间添加空格

Dan*_*Dan 6 r color-key lattice levelplot

我试图用来levelplot绘制一个简单的数字高程模型(DEM).

这是我的代码:

r1 = raster("ned10dem.tif")
e = extent(460000,480000,4555000,4567500)
rr1 = crop(r1,e)
p = levelplot(rr1, scales=list(x=list(at=seq(450000,480000,4000))),
              margin=F, cuts=200,
              col.regions = terrain.colors(350,alpha=1), 
              colorkey=list(space="bottom"),
              xlab="Easting(m)", ylab="Northing(m)")
plot(p)
Run Code Online (Sandbox Code Playgroud)

情节最终看起来像这样:

levelplot

我无法弄清楚的是如何增加colorkey和x轴之间的空间,使得colorkey不会覆盖x轴标签.

rcs*_*rcs 6

添加以下内容:

par.settings = list(layout.heights=list(xlab.key.padding=1))
Run Code Online (Sandbox Code Playgroud)

测试示例:

x <- seq(pi/4, 5*pi, length.out=100)
y <- seq(pi/4, 5*pi, length.out=100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
p <- levelplot(z~x+y, data=grid,
               margin=F, cuts=200,
               par.settings=list(layout.heights=list(xlab.key.padding=1)),
               col.regions=terrain.colors(350, alpha=1), 
               colorkey=list(space="bottom"),
               xlab="Easting(m)", ylab="Northing(m)")
print(p)
Run Code Online (Sandbox Code Playgroud)

levelplot