R - display multiple rasters using layout

In R (Win64), I try to build a combination of raster images and histograms in one graph window using the layout () command with a matrix that defines the layout. Here is sample code with simplified data:

library(raster)

r <- raster(ncols=5, nrows=5, xmn=1, xmx=5, ymn=1, ymx=5)
rast1 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25))
rast2 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25))
rast3 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25))

layout(matrix(c(1,2,3,4,1,2,3,5,1,2,3,6), 3, 4, byrow=T))
layout.show(6)

plot(rast1, axes=F, ann=F, legend=F, box=F, useRaster=T)
plot(rast2, axes=F, ann=F, legend=F, box=F, useRaster=T)
plot(rast3, axes=F, ann=F, legend=F, box=F, useRaster=T)
hist(rnorm(100), ann=F, axes=F)
hist(rnorm(100), ann=F, axes=F)
hist(rnorm(100), ann=F, axes=F)

As you can see, I am trying to build three raster images (rast1, rast2, rast3) that span 1 column and 3 rows each, with three histograms next to them, each of which spans 1 column and 1 row. The layout.show () command gives this idea.

, , ( ) , 3x4 ( ). , . .

, - plot() {raster}, layout(), , . ? ? reset ?

.

+5
1

S4 layout(). , , plot() (). (rast1, axes = F, ann = F, legend = F, box = F, useRaster = T), (rast1, axes = F, ann = F, asp = 1), .

+4

All Articles