Geographic Information Systems Asked on June 22, 2021
I want to plot 10 rasters using levelplot but I want to arrange the plots in such a way that there’s 1 plot in first row (in the center) and then 3 plots in next three rows. The idea is to show the "control" raster at the top and the month rasters below it (i.e. starting from the next row) so as to make comparisons easier.
#Desired Output looks something like this (numbers being individual plots)
1
2 3 4
5 6 7
8 9 10
I am using the below code but it plots them sequentially, one after the other (obviously).
library(raster)
library(rasterVis)
library(lattice)
library(grid)
library(RColorBrewer)
#sample data
s <- stack(replicate(10, raster(matrix(runif(100), 10))))
col1 <- colorRampPalette(c("#00008B", "#1874CD", "#00BFFF", "#76EE00", "#006400", "#FFB90F", "#EE7600", "#8B2323"))
mk.attr = c('Control', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September')
levelplot(s, xlab = NULL, ylab = NULL, col.regions = col1, names.attr = mk.attr,
colorkey = list(space = "right", labels = list(cex=1, font=2, col="brown"),
height=1, width=1.4,
row=4, column=3, hjust = 2),
main = list(label = "Main Title", cex = 1.2), margin = FALSE)
#add axis title
grid::grid.text(label = "Trends (in mm/year)", x = unit(0.90, "npc"), y = unit(0.50, "npc"), rot = 90,
gp = gpar(fontface = "bold", col = "gray33", fontsize = 11))
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP