diff --git a/R/VizCombinedMap.R b/R/VizCombinedMap.R index 38e42a0cd2891a5c1449a3375266619fd2d7e373..484d4efd59ebc4b256c57515a1a2c52ad16fd1b2 100644 --- a/R/VizCombinedMap.R +++ b/R/VizCombinedMap.R @@ -280,13 +280,13 @@ VizCombinedMap <- function(maps, lon, lat, var_limits_maps <- range(maps, na.rm = TRUE) if (is.null(bar_limits)) bar_limits <- display_range nmap <- dim(maps)[map_dim] - colorbar <- GradientCatsColorBar(nmap = nmap, - brks = brks, cols = cols, vertical = FALSE, - subsampleg = NULL, bar_limits = bar_limits, - var_limits = var_limits_maps, - triangle_ends = triangle_ends, col_inf = col_inf, col_sup = col_sup, plot = FALSE, draw_separators = TRUE, - bar_titles = bar_titles, title_scale = cex_bar_titles, label_scale = bar_label_scale * 1.5, - extra_margin = bar_extra_margin) + colorbar <- GradientCatsColorBar(nmap = nmap, + brks = brks, cols = cols, vertical = FALSE, subsampleg = NULL, + bar_limits = bar_limits, var_limits = var_limits_maps, + triangle_ends = triangle_ends, col_inf = col_inf, col_sup = col_sup, + plot = FALSE, draw_separators = TRUE, bar_titles = bar_titles, + title_scale = cex_bar_titles, label_scale = bar_label_scale * 1.5, + bar_extra_margin = bar_extra_margin) # Check bar_label_scale if (!is.numeric(bar_label_scale)) { @@ -487,7 +487,7 @@ VizCombinedMap <- function(maps, lon, lat, data = ml_map, lon = lon, lat = lat, brks = tbrks, cols = tcols, drawleg = FALSE, filled.continents = FALSE, country.borders = country.borders.VizEquiMap, - dots = dots, margin_scale = plot_margin + dots = dots, margin_scale = margin_scale, bar_extra_margin = bar_extra_margin ), args)) #---------------------- @@ -549,12 +549,11 @@ VizCombinedMap <- function(maps, lon, lat, if (drawleg & !return_leg) { GradientCatsColorBar(nmap = dim(maps)[map_dim], brks = colorbar$brks, cols = colorbar$cols, vertical = FALSE, - subsampleg = NULL, bar_limits = bar_limits, - var_limits = var_limits_maps, - triangle_ends = triangle_ends, col_inf = colorbar$col_inf, col_sup = colorbar$col_sup, - plot = TRUE, draw_separators = TRUE, - bar_titles = bar_titles, title_scale = cex_bar_titles, label_scale = bar_label_scale * 1.5, - extra_margin = bar_extra_margin) + subsampleg = NULL, bar_limits = bar_limits, var_limits = var_limits_maps, + triangle_ends = triangle_ends, col_inf = colorbar$col_inf, + col_sup = colorbar$col_sup, plot = TRUE, draw_separators = TRUE, + bar_titles = bar_titles, title_scale = cex_bar_titles, + label_scale = bar_label_scale * 1.5, bar_extra_margin = bar_extra_margin) } if (!return_leg) { diff --git a/R/VizMostLikelyQuantileMap.R b/R/VizMostLikelyQuantileMap.R index a756b4eb6919d84ea8ab1201a534573e0156a0bb..cc849fe029953dd12ce61bac317f32a5a06f3147 100644 --- a/R/VizMostLikelyQuantileMap.R +++ b/R/VizMostLikelyQuantileMap.R @@ -38,6 +38,13 @@ #' 'down', 'd', 'D', 'bottom', 'b', 'B', 'south', 's', 'S' (default)\cr #' 'right', 'r', 'R', 'east', 'e', 'E'\cr #' 'left', 'l', 'L', 'west', 'w', 'W' +#'@param margin_scale Numeric vector of length 4 specifying the plot margins +#' (excluding the color bar), in the order: bottom, left, top, and right. If +#' not specified (NULL), the default margins from \code{par("mar")}, which are +#' c(5.1, 4.1, 4.1, 2.1), are used. Default is NULL. +#'@param bar_extra_margin Numeric vector of length 4 specifying the margins to +#' be added around the color bar, in the order: bottom, left, top, and right. +#' The units are margin lines. The default values are c(1.5, 0, 1.5, 0). #'@param ... Additional parameters to be sent to \code{VizCombinedMap} and #' \code{VizEquiMap}. #'@seealso \code{VizCombinedMap} and \code{VizEquiMap} @@ -101,7 +108,8 @@ VizMostLikelyQuantileMap <- function(probs, lon, lat, cat_dim = 'bin', bar_titles = NULL, col_unknown_cat = 'white', drawleg = T, - ...) { + margin_scale = NULL, + bar_extra_margin = c(1.5, 0, 1.5, 0), ...) { # Check probs error <- FALSE if (is.list(probs)) { @@ -182,5 +190,6 @@ VizMostLikelyQuantileMap <- function(probs, lon, lat, cat_dim = 'bin', VizCombinedMap(probs * 100, lon, lat, map_select_fun = max, display_range = c(minimum_value, 100), map_dim = cat_dim, bar_titles = bar_titles, col_unknown_map = col_unknown_cat, - drawleg = drawleg, ...) + drawleg = drawleg, margin_scale = margin_scale, + bar_extra_margin = bar_extra_margin, ...) } \ No newline at end of file diff --git a/R/zzz.R b/R/zzz.R index cf2eb1c72f75cd60bbaafe18dddb6913d2d316ae..3a43b40d431e349a926bf34d8b30d69833e65a38 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -110,7 +110,7 @@ GradientCatsColorBar <- function(nmap, brks = NULL, cols = NULL, vertical = TRUE bar_limits, var_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, plot = TRUE, draw_separators = FALSE, - bar_titles = NULL, title_scale = 1, label_scale = 1, extra_margin = rep(0, 4), + bar_titles = NULL, title_scale = 1, bar_label_scale = 1, bar_extra_margin = rep(0, 4), ...) { # bar_limits: a vector of 2 or a list @@ -236,7 +236,7 @@ GradientCatsColorBar <- function(nmap, brks = NULL, cols = NULL, vertical = TRUE triangle_ends = triangle_ends, col_inf = col_inf[[k]], col_sup = col_sup[[k]], plot = TRUE, draw_separators = draw_separators, title = bar_titles[[k]], title_scale = title_scale, - label_scale = label_scale, extra_margin = extra_margin) + bar_label_scale = bar_label_scale, bar_extra_margin = bar_extra_margin) } } else { return(list(brks = brks, cols = cols, col_inf = col_inf, col_sup = col_sup))