Edit margin in levelplot

37 Views Asked by At

I have 11 models, and for each model, I have 4 datasets. I want to create a plot using levelplot from the latticeExtra package to visualize these datasets. However, when I tried using layout = c(4,11), the plot was very small and unreadable. There is so much space.

enter image description here

Here's my current code:

p2 <- levelplot(
  margin = FALSE,
  stack(c(slope_obs, slope_cmip6)),
  pretty = TRUE,
  main = "Sen's Slope",
  names.attr = indices[1:44],
  layout = c(4, 11),
  at = seq(-2, 2, 0.5),
  col.regions = brewer.pal(9, "YlGnBu"),
  ylab = list("Latitude", cex.lab = 1.2, fontlab = 2, col.lab = "black"),
  xlab = "",
  cex.names = 0.8,
  colorkey = list(
    space = "right",
    labels = list(
      at = seq(-2, 2, 1),
      labels = seq(-2, 2,1),
      cex = 0.8
    ),
    title = list("mm/year", rot = 0, cex = 0.8, font = 1, col = "black")
  ),
  par.settings = list(
    axis.line = list(col = "black", lwd = 0.8),
    strip.background = list(col = "lightgray"),
    strip.shingle = list(col = "transparent"),
    strip.border = list(col = "black", lwd = 0.8),
    add.text = list(col = "black", font = 1, cex = 1),
    layout.heights = list(bottom.padding = 5)
    #panel.background = list(col="lightblue")
  ),

  #sub = "ERA5-Land and Model CMIP6, where N = 360 is the number of month in the baseline period (1981-2010)",
  panel = function(...) {
    panel.levelplot(...)
    #panel.raster(ocean_raster, interpolate = TRUE, col = "lightblue")
    panel.grid(h = 4, v = 4, col = "black", lty = 2, lwd = 0.2)
  }
)
0

There are 0 best solutions below