Commit cc33fb19 authored by aho's avatar aho
Browse files

Add filled.oceans feature

parent f7018404
Pipeline #5776 passed with stage
in 4 minutes and 12 seconds
......@@ -60,6 +60,9 @@
#'@param filled.continents Colour to fill in drawn projected continents.
#' Takes the value gray(0.5) by default or, if 'square = FALSE', takes the
#' value FALSE. If set to FALSE, continents are not filled in.
#'@param filled.oceans A logical value or the color name to fill in drawn
#' projected oceans. The default value is FALSE. If it is TRUE, the default
#' colour is "light blue".
#'@param coast_color Colour of the coast line of the drawn projected continents.
#' Takes the value gray(0.5) by default.
#'@param coast_width Line width of the coast line of the drawn projected
......@@ -224,6 +227,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,
filled.oceans = FALSE,
coast_color = NULL, coast_width = 1, lake_color = NULL,
contours = NULL, brks2 = NULL, contour_lwd = 0.5,
contour_color = 'black', contour_lty = 1,
......@@ -419,6 +423,16 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL,
continent_color <- gray(0.5)
}
# Check filled.oceans
if (!.IsColor(filled.oceans) & !is.logical(filled.oceans)) {
stop("Parameter 'filled.oceans' must be logical or a colour identifier.")
} else if (!is.logical(filled.oceans)) {
ocean_color <- filled.oceans
filled.oceans <- TRUE
} else if (filled.oceans) {
ocean_color <- "light blue"
}
# Check coast_color
if (is.null(coast_color)) {
if (filled.continents) {
......@@ -442,8 +456,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL,
lake_color <- 'white'
}
} else {
if (!.IsColor(coast_color)) {
stop("Parameter 'coast_color' must be a valid colour identifier.")
if (!.IsColor(lake_color)) {
stop("Parameter 'lake_color' must be a valid colour identifier.")
}
}
......@@ -836,6 +850,22 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL,
} else {
lines(coast, col = coast_color, lwd = coast_width)
}
# filled.oceans
if (filled.oceans) {
old_lwd <- par('lwd')
par(lwd = coast_width)
outline <- map(continents, fill = T, plot = FALSE) # must be fill = T
xbox <- xlim_conti + c(-2, 2)
ybox <- c(-92, 92)
outline$x <- c(outline$x, NA, c(xbox, rev(xbox), xbox[1]))
outline$y <- c(outline$y, NA, rep(ybox, each = 2), ybox[1])
polypath(outline, col = ocean_color, rule = 'evenodd', border = NA)
par(lwd = old_lwd)
}
box()
# Draw rectangle on the map
if (!is.null(boxlim)) {
......
......@@ -23,6 +23,7 @@ PlotEquiMap(
color_fun = clim.palette(),
square = TRUE,
filled.continents = NULL,
filled.oceans = FALSE,
coast_color = NULL,
coast_width = 1,
lake_color = NULL,
......@@ -140,6 +141,10 @@ the spaces in between with colours (FALSE). In the latter case,
Takes the value gray(0.5) by default or, if 'square = FALSE', takes the
value FALSE. If set to FALSE, continents are not filled in.}
\item{filled.oceans}{A logical value or the color name to fill in drawn
projected oceans. The default value is FALSE. If it is TRUE, the default
colour is "light blue".}
\item{coast_color}{Colour of the coast line of the drawn projected continents.
Takes the value gray(0.5) by default.}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment