r - levelplot: how to add space between colorkey and x-axis label -
i trying use levelplot
plot simple digital elevation model (dem).
here code:
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)
the plot ends looking this:
what cannot figure out how increase space between colorkey , x-axis such colorkey not cover x-axis label.
add following:
par.settings = list(layout.heights=list(xlab.key.padding=1))
test example:
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)
Comments
Post a Comment