Skip to content

PlotLayout + PlotMostLikelyQuantileMap

library(abind)
x <- array(1:(20 * 10 * 3), dim = c(lat = 10, lon = 20, time = 3)) / 200
a <- x * 0.6
b <- (1 - x) * 0.6
c <- 1 - (a + b)
lons <- seq(0, 359.5, length = 20)
lats <- seq(-89.5, 89.5, length = 10)
probs <- abind(a, b, c, along = 0)
dim(probs) <- c("bin" = 3, dim(a))
# NEW LINE: Reorder dimensions
probs <- Reorder(probs, c("time", "bin", "lon", "lat"))
# Single plot:
PlotMostLikelyQuantileMap(probs[1, , , ], lons, lats,
                         toptitle = 'Most likely tercile map',
                         bar_titles = paste('% of belonging to', c('a', 'b', 'c')), 
                         plot_margin = c(10.1, 8.1, 10.1, 8.1), bar_margin = c(1.5, 0, 1.5, 0), cex_bar_titles = 1.5,
                         brks = 20, width = 10, height = 8)

image

PlotLayout(PlotMostLikelyQuantileMap, c('bin', 'lon', 'lat'), cat_dim = 'bin',
           probs, lons, lats, drawleg = F,
           legend_scale = 0.8, cex_bar_titles = 0.8,
           bar_margin = c(0.1,0,0.1,0), plot_margin = c(2.1, 1.1, 2.1, 1.1),
#           toptitle = 'Most likely tercile map',
           titles = c("First", "Second", "Third"),  #without titles, error about old_mar in PlotCombinedMap
#           bar_titles = paste('% of belonging to', c('a', 'b', 'c')),
           brks = 20, width = 10, height = 8)

image