Dear Group,

I'd like to combine many grid::grid.raster plots into a single layout.

Here's my attempt, which does not work (i.e., does not combine the 9 images
into a single plot layout).

require(grid)

random_image <- function() {

  r <- matrix(sample(1:255, 32 * 32, replace = TRUE), nrow = 32, ncol = 32)
  g <- matrix(sample(1:255, 32 * 32, replace = TRUE), nrow = 32, ncol = 32)
  b <- matrix(sample(1:255, 32 * 32, replace = TRUE), nrow = 32, ncol = 32)
  img <- rgb(r, g, b, maxColorValue = 255)
  dim(img) <- c(32, 32)
  img

}

set.seed(1)
layout(matrix(1:9,nr=3,byr=T))
for (i in 1:9) {
 image <- random_image()
 grid.raster(image)
}

Any guidance would be highly appreciated.

Best,
Axel.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to