From 87d89e5fe7da9d0eb8451257f1eb40f820fd5f20 Mon Sep 17 00:00:00 2001 From: aho Date: Mon, 7 Jun 2021 17:27:49 +0200 Subject: [PATCH 1/3] Add parameter 'contour_draw_label' to decide whether to draw the contour labels or not. --- R/PlotEquiMap.R | 11 +++++++++-- man/PlotEquiMap.Rd | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index c0fa89db..79c22a27 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -75,6 +75,8 @@ #' and 'brks2', or if 'square = FALSE'. #'@param contour_lty Line type of the contour curves. Takes 1 (solid) by #' default. See help on 'lty' in par() for other accepted values. +#'@param contour_draw_label A logical value indicating whether to draw the +#' contour labels or not. The default value is TRUE. #'@param contour_label_scale Scale factor for the superimposed labels when #' drawing contour levels. #'@param dots Array of same dimensions as 'var' or with dimensions @@ -224,7 +226,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, coast_color = NULL, coast_width = 1, contours = NULL, brks2 = NULL, contour_lwd = 0.5, contour_color = 'black', contour_lty = 1, - contour_label_scale = 1, + contour_draw_label = TRUE, contour_label_scale = 1, dots = NULL, dot_symbol = 4, dot_size = 1, arr_subsamp = floor(length(lon) / 30), arr_scale = 1, arr_ref_len = 15, arr_units = "m/s", @@ -468,6 +470,11 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, stop("Parameter 'contour_lty' must be either a number or a character string.") } + # Check contour_draw_label + if (!is.logical(contour_draw_label)) { + stop("Parameter 'contour_draw_label' must be logical.") + } + # Check contour_label_scale if (!is.numeric(contour_label_scale)) { stop("Parameter 'contour_label_scale' must be numeric.") @@ -749,7 +756,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # labcex = cex_axes_labels, labcex = contour_label_scale * par("cex"), lwd = contour_lwd, lty = contour_lty, - col = contour_color) + col = contour_color, drawlabels = contour_draw_label) } # diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index c9db45b5..8532137c 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -30,6 +30,7 @@ PlotEquiMap( contour_lwd = 0.5, contour_color = "black", contour_lty = 1, + contour_draw_label = TRUE, contour_label_scale = 1, dots = NULL, dot_symbol = 4, @@ -158,6 +159,9 @@ and 'brks2', or if 'square = FALSE'.} \item{contour_lty}{Line type of the contour curves. Takes 1 (solid) by default. See help on 'lty' in par() for other accepted values.} +\item{contour_draw_label}{A logical value indicating whether to draw the +contour labels or not. The default value is TRUE.} + \item{contour_label_scale}{Scale factor for the superimposed labels when drawing contour levels.} -- GitLab From e671522ce311079a24d5f4c84876e665b68e9171 Mon Sep 17 00:00:00 2001 From: aho Date: Mon, 7 Jun 2021 18:10:05 +0200 Subject: [PATCH 2/3] Add parameter 'lake_color' to specify lake color when filled.continents = T --- R/PlotEquiMap.R | 18 ++++++++++++++++-- man/PlotEquiMap.Rd | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index 79c22a27..e0e02fbc 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -64,6 +64,9 @@ #' Takes the value gray(0.5) by default. #'@param coast_width Line width of the coast line of the drawn projected #' continents. Takes the value 1 by default. +#'@param lake_color Colour of the lake or other water body inside continents. +#' It is only functional when 'filled.continents = TRUE'. The default value is +#' 'white'. #'@param contours Array of same dimensions as 'var' to be added to the plot #' and displayed with contours. Parameter 'brks2' is required to define the #' magnitude breaks for each contour curve. Disregarded if 'square = FALSE'. @@ -223,7 +226,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, colNA = NULL, color_fun = clim.palette(), square = TRUE, filled.continents = NULL, - coast_color = NULL, coast_width = 1, + coast_color = NULL, coast_width = 1, lake_color = NULL, contours = NULL, brks2 = NULL, contour_lwd = 0.5, contour_color = 'black', contour_lty = 1, contour_draw_label = TRUE, contour_label_scale = 1, @@ -434,6 +437,17 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, stop("Parameter 'coast_width' must be numeric.") } + # Check lake_color + if (is.null(lake_color)) { + if (filled.continents) { + lake_color <- 'white' + } + } else { + if (!.IsColor(coast_color)) { + stop("Parameter 'coast_color' must be a valid colour identifier.") + } + } + # Check contours if (!is.null(contours)) { if (dim(contours)[1] != dims[1] || dim(contours)[2] != dims[2]) { @@ -799,7 +813,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, LAT0 = mean(ylat), LATS = ylat, LONS = xlon) lakes <- which(coastmap$STROKES$col == "blue") coastmap$STROKES$col[which(coastmap$STROKES$col != "blue")] <- continent_color - coastmap$STROKES$col[lakes] <- "white" + coastmap$STROKES$col[lakes] <- lake_color #"white" par(new = TRUE) GEOmap::plotGEOmap(coastmap, PROJ = proj, border = coast_color, add = TRUE, lwd = coast_width) diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 8532137c..18456bed 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -25,6 +25,7 @@ PlotEquiMap( filled.continents = NULL, coast_color = NULL, coast_width = 1, + lake_color = NULL, contours = NULL, brks2 = NULL, contour_lwd = 0.5, @@ -143,6 +144,10 @@ Takes the value gray(0.5) by default.} \item{coast_width}{Line width of the coast line of the drawn projected continents. Takes the value 1 by default.} +\item{lake_color}{Colour of the lake or other water body inside continents. +It is only functional when 'filled.continents = TRUE'. The default value is +'white'.} + \item{contours}{Array of same dimensions as 'var' to be added to the plot and displayed with contours. Parameter 'brks2' is required to define the magnitude breaks for each contour curve. Disregarded if 'square = FALSE'.} -- GitLab From 335314dde09795a26ce76b7b51b5818835344a59 Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 8 Jun 2021 08:36:32 +0200 Subject: [PATCH 3/3] Fix the statement & to | --- R/StatSeasAtlHurr.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/StatSeasAtlHurr.R b/R/StatSeasAtlHurr.R index 43d41b65..7cee7a03 100644 --- a/R/StatSeasAtlHurr.R +++ b/R/StatSeasAtlHurr.R @@ -136,7 +136,7 @@ StatSeasAtlHurr <- function(atlano = NULL, tropano = NULL, hrvar = "HR") { # mean. PDI follows a gamma distribution, with sigma = # -0.57. (variance = sigma^2 * mean^2). # ----------------------------------------------------------- - if (hrvar == "HR" && hrvar == "TC") { + if (hrvar == "HR" | hrvar == "TC") { statval$var <- statval$mean } else { sigma <- -0.57 -- GitLab