diff --git a/R/AnimateMap.R b/R/AnimateMap.R index 22f6e9fca3e54ef81d789da58056c3514a4f83ff..86bacf35fd13322d1df124499e912eb757f85ff8 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -45,9 +45,7 @@ AnimateMap <- function(var, lon, lat, toptitle = c("", "", "", if (length(lon) != nlon | length(lat) != nlat) { stop("Inconsistent var dimensions / longitudes + latitudes") } - colorbar <- colorRampPalette(c("dodgerblue4", "dodgerblue1", - "forestgreen", "yellowgreen", "white", "white", "yellow", - "orange", "red", "saddlebrown")) + colorbar <- clim.palette() if (is.null(brks) == TRUE) { ll <- signif(min(var[, , 2, , , ], na.rm = TRUE), 4) ul <- signif(max(var[, , 2, , , ], na.rm = TRUE), 4) diff --git a/R/Ano.R b/R/Ano.R index a926144d55440a80745ed5a8ea0f9bb1de2d5312..4b2b8767b240b8c867dd3f92cf62600ed31510d9 100644 --- a/R/Ano.R +++ b/R/Ano.R @@ -4,6 +4,10 @@ Ano <- function(var, clim) { # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # dimvar <- dim(var) + + if (length(dim(clim)) <= 2) { + clim <- InsertDim(clim, 2, dimvar[2]) + } if ((length(dimvar) > length(dim(clim))) & (dim(clim)[2] != dimvar[2])) { clim <- InsertDim(clim, 2, dimvar[2]) } @@ -13,13 +17,13 @@ Ano <- function(var, clim) { if ((length(dimvar) > length(dim(clim))) & (dim(clim)[4] != dimvar[4])) { clim <- InsertDim(clim, 4, dimvar[4]) } - + # # Raw anomalies # ~~~~~~~~~~~~~~~ # ano <- var - clim - + # # Outputs # ~~~~~~~~~ diff --git a/R/ColorBar.R b/R/ColorBar.R index fb2f0a2873c64eb7654bf2f86d183265f62d10e9..eb01a9ae799e1812b8b06272df1dab42d21eff70 100644 --- a/R/ColorBar.R +++ b/R/ColorBar.R @@ -1,12 +1,19 @@ ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, subsampleg = NULL, bar_limits = NULL, var_limits = NULL, - triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - color_fun = clim.colors, plot = TRUE, draw_ticks = TRUE, - draw_separators = FALSE, triangle_ends_scale = 1, - extra_labels = NULL, title = NULL, title_scale = 1, + triangle_ends = NULL, col_inf = NULL, col_sup = NULL, + color_fun = clim.palette(), plot = TRUE, + draw_ticks = TRUE, draw_separators = FALSE, + triangle_ends_scale = 1, extra_labels = NULL, + title = NULL, title_scale = 1, label_scale = 1, tick_scale = 1, extra_margin = rep(0, 4), label_digits = 4, ...) { # Required checks + if ((is.null(brks) || length(brks) < 2) && is.null(bar_limits) && is.null(var_limits)) { + stop("At least one of 'brks' with the desired breaks, 'bar_limits' or ", + "'var_limits' must be provided to generate the colour bar.") + } + + # Check brks if (!is.null(brks)) { if (!is.numeric(brks)) { stop("Parameter 'brks' must be numeric if specified.") @@ -16,41 +23,86 @@ ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, cols <- cols[reorder$ix[which(reorder$ix <= length(cols))]] } brks <- reorder$x - } + } } - if ((is.null(brks) || length(brks) < 2) && is.null(var_limits)) { - stop("At least one of 'brks' with the desired breaks or 'var_limits' must be provided to generate the colour bar.") + + # Check bar_limits + if (!is.null(bar_limits)) { + if (!(all(is.na(bar_limits) | is.numeric(bar_limits)) && (length(bar_limits) == 2))) { + stop("Parameter 'bar_limits' must be a vector of two numeric elements or NAs.") + } } # Check var_limits - if (is.null(var_limits)) { - var_limits <- c(head(brks, 1), tail(brks, 1)) - } else if (!is.numeric(var_limits) || length(var_limits) != 2) { - stop("Parameter 'var_limits' must be a numeric vector with two elements.") - } else if (any(is.na(var_limits))) { - stop("Parameter 'var_limits' must not contain NA values.") - } else if (any(is.infinite(var_limits))) { - stop("Parameter 'var_limits' must no contain infinite values.") + if (!is.null(var_limits)) { + if (!(is.numeric(var_limits) && (length(var_limits) == 2))) { + stop("Parameter 'var_limits' must be a numeric vector of length 2.") + } else if (any(is.na(var_limits))) { + stop("Parameter 'var_limits' must not contain NA values.") + } else if (any(is.infinite(var_limits))) { + stop("Parameter 'var_limits' must not contain infinite values.") + } } - # Check bar_limits - if (is.null(bar_limits)) { - if (!is.null(brks) && length(brks) > 1) { - bar_limits <- c(head(brks, 1), tail(brks, 1)) - } else { - bar_limits <- var_limits + # Check cols + if (!is.null(cols)) { + if (!is.character(cols)) { + stop("Parameter 'cols' must be a vector of character strings.") + } else if (any(!sapply(cols, .IsColor))) { + stop("Parameter 'cols' must contain valid colour identifiers.") } - } else if ((!is.numeric(bar_limits) && !all(is.na(bar_limits))) || length(bar_limits) != 2) { - stop("Parameter 'bar_limits' must be a numeric vector with two elements.") - } else { - bar_limits[which(is.na(bar_limits))] <- var_limits[which(is.na(bar_limits))] } # Check color_fun if (!is.function(color_fun)) { stop("Parameter 'color_fun' must be a colour-generator function.") } - + + # Check integrity among brks, bar_limits and var_limits + if (is.null(brks) || (length(brks) < 2)) { + if (is.null(brks)) { + if (is.null(cols)) { + brks <- 21 + } else { + brks <- length(cols) + 1 + } + } + if (is.null(bar_limits) || any(is.na(bar_limits))) { + # var_limits is defined + if (is.null(bar_limits)) { + bar_limits <- c(NA, NA) + } + half_width <- 0.5 * (var_limits[2] - var_limits[1]) / (brks - 1) + bar_limits[which(is.na(bar_limits))] <- c(var_limits[1] - half_width, var_limits[2] + half_width)[which(is.na(bar_limits))] + brks <- seq(bar_limits[1], bar_limits[2], length.out = brks) + } else if (is.null(var_limits)) { + # bar_limits is defined + brks <- seq(bar_limits[1], bar_limits[2], length.out = brks) + var_limits <- bar_limits + var_limits[1] <- var_limits[1] + .Machine$double.xmin + } else { + # both bar_limits and var_limits are defined + brks <- seq(bar_limits[1], bar_limits[2], length.out = brks) + } + } else if (is.null(bar_limits)) { + if (is.null(var_limits)) { + # brks is defined + bar_limits <- c(head(brks, 1), tail(brks, 1)) + var_limits <- bar_limits + var_limits[1] <- var_limits[1] + .Machine$double.xmin + } else { + # brks and var_limits are defined + bar_limits <- c(head(brks, 1), tail(brks, 1)) + } + } else { + # brks and bar_limits are defined + # or + # brks, bar_limits and var_limits are defined + if (head(brks, 1) != bar_limits[1] || tail(brks, 1) != bar_limits[2]) { + stop("Parameters 'brks' and 'bar_limits' are inconsistent.") + } + } + # Check col_inf if (!is.null(col_inf)) { if (!.IsColor(col_inf)) { @@ -68,11 +120,11 @@ ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, # Check triangle_ends if (!is.null(triangle_ends) && (!is.logical(triangle_ends) || length(triangle_ends) != 2)) { stop("Parameter 'triangle_ends' must be a logical vector with two elements.") - } + } teflc <- triangle_ends_from_limit_cols <- c(!is.null(col_inf), !is.null(col_sup)) if (is.null(triangle_ends) && is.null(col_inf) && is.null(col_sup)) { triangle_ends <- c(FALSE, FALSE) - if (bar_limits[1] > var_limits[1]) { + if (bar_limits[1] >= var_limits[1]) { triangle_ends[1] <- TRUE } if (bar_limits[2] < var_limits[2]) { @@ -91,41 +143,34 @@ ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, triangle_ends <- triangle_ends } } - - # Check brks and cols - if (!is.null(cols)) { - if (!is.character(cols)) { - stop("Parameter 'cols' must be a character vector.") - } else if (any(!sapply(cols, .IsColor))) { - stop("Parameter 'cols' must contain valid colour identifiers.") + if (plot) { + if ((bar_limits[1] >= var_limits[1]) && !triangle_ends[1]) { + .warning("There are variable values smaller or equal to the lower limit ", + "of the colour bar and the lower triangle end has been ", + "disabled. These will be painted in the colour for NA values.") } - } - if (is.null(brks)) { - if (!is.null(cols)) { - brks <- length(cols) + 1 - } else { - brks <- 21 + if ((bar_limits[2] < var_limits[2]) && !triangle_ends[2]) { + .warning("There are variable values greater than the higher limit ", + "of the colour bar and the higher triangle end has been ", + "disabled. These will be painted in the colour for NA values.") } } - if (is.numeric(brks)) { - if (length(brks) == 1) { - brks <- seq(bar_limits[1], bar_limits[2], length.out = brks) + + # Generate colours if needed + if (is.null(cols)) { + cols <- color_fun(length(brks) - 1 + sum(triangle_ends)) + attr_bk <- attributes(cols) + if (triangle_ends[1]) { + if (is.null(col_inf)) col_inf <- head(cols, 1) + cols <- cols[-1] } - if (is.null(cols)) { - cols <- color_fun(length(brks) - 1 + sum(triangle_ends)) - if (triangle_ends[1]) { - if (is.null(col_inf)) col_inf <- head(cols, 1) - cols <- cols[-1] - } - if (triangle_ends[2]) { - if (is.null(col_sup)) col_sup <- tail(cols, 1) - cols <- cols[-length(cols)] - } - } else if ((length(cols) != (length(brks) - 1))) { - stop("Incorrect number of 'brks' and 'cols'. There must be one more break than the number of colours.") + if (triangle_ends[2]) { + if (is.null(col_sup)) col_sup <- tail(cols, 1) + cols <- cols[-length(cols)] } - } else { - stop("Parameter 'brks' must be a numeric vector.") + attributes(cols) <- attr_bk + } else if ((length(cols) != (length(brks) - 1))) { + stop("Incorrect number of 'brks' and 'cols'. There must be one more break than the number of colours.") } # Check vertical diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index dea625df467a81c26fb406e476e3b3036eaf306e..84173ec8a740db7b45c3c7372bb68fe9488970c9 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -1,8 +1,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, sizetit = NULL, units = NULL, - brks = NULL, cols = NULL, bar_limits = NULL, + brks = NULL, cols = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - colNA = 'white', color_fun = clim.colors, + colNA = NULL, color_fun = clim.palette(), square = TRUE, filled.continents = NULL, coast_color = NULL, coast_width = 1, contours = NULL, brks2 = NULL, contour_lwd = 0.5, @@ -131,16 +131,11 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, title_scale <- sizetit } - # Check colNA - if (!.IsColor(colNA)) { - stop("Parameter 'colNA' must be a valid colour identifier.") - } - + var_limits <- c(min(var, na.rm = TRUE), max(var, na.rm = TRUE)) # Check: brks, cols, subsampleg, bar_limits, color_fun, bar_extra_labels, draw_bar_ticks # draw_separators, triangle_ends_scale, label_scale, units, units_scale, # bar_label_digits # Build: brks, cols, bar_limits, col_inf, col_sup - var_limits <- c(min(var, na.rm = TRUE), max(var, na.rm = TRUE)) colorbar <- ColorBar(brks, cols, FALSE, subsampleg, bar_limits, var_limits, triangle_ends, col_inf, col_sup, color_fun, FALSE, extra_labels = bar_extra_labels, draw_ticks = draw_bar_ticks, @@ -155,6 +150,20 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, col_sup <- colorbar$col_sup bar_limits <- c(head(brks, 1), tail(brks, 1)) + # Check colNA + if (is.null(colNA)) { + if ('na_color' %in% names(attributes(cols))) { + colNA <- attr(cols, 'na_color') + if (!.IsColor(colNA)) { + stop("The 'na_color' provided as attribute of the colour vector must be a valid colour identifier.") + } + } else { + colNA <- 'pink' + } + } else if (!.IsColor(colNA)) { + stop("Parameter 'colNA' must be a valid colour identifier.") + } + # Check square if (!is.logical(square)) { stop("Parameter 'square' must be logical.") diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 347007f0442d6da3e89d856fb4af68d4839a78da..f14199e9b706b84f00dab398e3a803dfb7f642a1 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -1,8 +1,8 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), toptitle = NULL, sizetit = NULL, units = NULL, - brks = NULL, cols = NULL, bar_limits = NULL, - triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - colNA = 'white', color_fun = clim.colors, + brks = NULL, cols = NULL, bar_limits = NULL, + triangle_ends = NULL, col_inf = NULL, col_sup = NULL, + colNA = NULL, color_fun = clim.palette(), filled.continents = FALSE, coast_color = NULL, coast_width = 1, dots = NULL, dot_symbol = 4, dot_size = 0.8, @@ -111,11 +111,6 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), title_scale <- sizetit } - # Check colNA - if (!.IsColor(colNA)) { - stop("Parameter 'colNA' must be a valid colour identifier.") - } - # Check: brks, cols, subsampleg, bar_limits, color_fun, bar_extra_labels, draw_bar_ticks # draw_separators, triangle_ends_scale, label_scale, units, units_scale, # bar_label_digits @@ -135,6 +130,20 @@ PlotStereoMap <- function(var, lon, lat, latlims = c(60, 90), col_sup <- colorbar$col_sup bar_limits <- c(head(brks, 1), tail(brks, 1)) + # Check colNA + if (is.null(colNA)) { + if ('na_color' %in% names(attributes(cols))) { + colNA <- attr(cols, 'na_color') + if (!.IsColor(colNA)) { + stop("The 'na_color' provided as attribute of the colour vector must be a valid colour identifier.") + } + } else { + colNA <- 'pink' + } + } else if (!.IsColor(colNA)) { + stop("Parameter 'colNA' must be a valid colour identifier.") + } + # Check filled.continents if (!.IsColor(filled.continents) && !is.logical(filled.continents)) { stop("Parameter 'filled.continents' must be logical or a colour identifier.") diff --git a/R/clim.colors.R b/R/clim.colors.R deleted file mode 100644 index f5c8ee5b1f507c5df398fe7abc72061e5836d4ad..0000000000000000000000000000000000000000 --- a/R/clim.colors.R +++ /dev/null @@ -1,6 +0,0 @@ -clim.colors <- function(n) { - colorbar <- colorRampPalette(c("dodgerblue4", "dodgerblue1", "forestgreen", - "yellowgreen", "white", "white", "yellow", - "orange", "red", "saddlebrown")) - colorbar(n) -} diff --git a/R/clim.palette.R b/R/clim.palette.R new file mode 100644 index 0000000000000000000000000000000000000000..5673c61d1e1d3bb53a069c36d8acab982aada337 --- /dev/null +++ b/R/clim.palette.R @@ -0,0 +1,32 @@ +clim.colors <- function(n, palette = "bluered") { + clim.palette(palette)(n) +} + +clim.palette <- function(palette = "bluered") { + if (palette == "bluered") { + colorbar <- colorRampPalette(rev(c("#67001f", "#b2182b", "#d6604d", + "#f4a582", "#fddbc7", "#f7f7f7", + "#d1e5f0", "#92c5de", "#4393c3", + "#2166ac", "#053061"))) + attr(colorbar, 'na_color') <- 'pink' + } else if (palette == "redblue") { + colorbar <- colorRampPalette(c("#67001f", "#b2182b", "#d6604d", + "#f4a582", "#fddbc7", "#f7f7f7", + "#d1e5f0", "#92c5de", "#4393c3", + "#2166ac", "#053061")) + attr(colorbar, 'na_color') <- 'pink' + } else if (palette == "yellowred") { + colorbar <- colorRampPalette(c("#ffffcc", "#ffeda0", "#fed976", + "#feb24c", "#fd8d3c", "#fc4e2a", + "#e31a1c", "#bd0026", "#800026")) + attr(colorbar, 'na_color') <- 'pink' + } else if (palette == "redyellow") { + colorbar <- colorRampPalette(rev(c("#ffffcc", "#ffeda0", "#fed976", + "#feb24c", "#fd8d3c", "#fc4e2a", + "#e31a1c", "#bd0026", "#800026"))) + attr(colorbar, 'na_color') <- 'pink' + } else { + stop("Parameter 'palette' must be one of 'bluered', 'redblue', 'yellowred' or 'redyellow'.") + } + colorbar +} diff --git a/man/ColorBar.Rd b/man/ColorBar.Rd index 98d2f31a36c10b6975706e1e084ec39e4a561949..fb7cc7e508b23f6d87773077c3313436a1f03827 100644 --- a/man/ColorBar.Rd +++ b/man/ColorBar.Rd @@ -10,7 +10,7 @@ The only mandatory parameters are 'var_limits' or 'brks' (in its second format, ColorBar(brks = NULL, cols = NULL, vertical = TRUE, subsampleg = NULL, bar_limits = NULL, var_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - color_fun = clim.colors, plot = TRUE, draw_ticks = TRUE, + color_fun = clim.palette(), plot = TRUE, draw_ticks = TRUE, draw_separators = FALSE, triangle_ends_scale = 1, extra_labels = NULL, title = NULL, title_scale = 1, label_scale = 1, tick_scale = 1, @@ -51,7 +51,7 @@ Colour to fill the inferior triangle end with. Useful if specifying colours manu Colour to fill the superior triangle end with. Useful if specifying colours manually with parameter 'cols', to specify the colour and to trigger the drawing of the upper extreme triangle, or if 'cols' is not specified, to replace the colour automatically generated by ColorBar(). } \item{color_fun}{ -Function to generate the colours of the color bar. Must take an integer and must return as many colours. Set by default to clim.colors. +Function to generate the colours of the color bar. Must take an integer and must return as many colours. The returned colour vector can have the attribute 'na_color', with a colour to draw NA values. This parameter is set by default to clim.palette(). } \item{plot}{ Logical value indicating whether to only compute its breaks and colours (FALSE) or to also draw it on the current device (TRUE). diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 9ba2ca4909ffdcb5da86232d6ffa99437ac14366..23e142eafa1e13e434c37f780b99c4bb47deda1e 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -11,7 +11,7 @@ PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, sizetit = NULL, units = NULL, brks = NULL, cols = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - colNA = 'white', color_fun = clim.colors, + colNA = NULL, color_fun = clim.palette(), square = TRUE, filled.continents = NULL, coast_color = NULL, coast_width = 1, contours = NULL, brks2 = NULL, contour_lwd = 0.5, @@ -64,7 +64,7 @@ Title at the top of the colour bar, most commonly the units of the variable prov Usually only providing 'brks' is enough to generate the desired colour bar. These parameters allow to define n breaks that define n - 1 intervals to classify each of the values in 'var'. The corresponding grid cell of a given value in 'var' will be coloured in function of the interval it belongs to. These parameters are sent to \code{ColorBar()} to generate the breaks and colours. Additional colours for values beyond the limits of the colour bar are also generated and applied to the plot if 'bar_limits' or 'brks' and 'triangle_ends' are properly provided to do so. See ?ColorBar for a full explanation.\cr } \item{col_inf,col_sup,colNA}{ -Colour identifiers to colour the values in 'var' that go beyond the extremes of the colour bar and to colour NA values, respectively. 'colNA' takes 'white' by default. 'col_inf' and 'col_sup' will take the value of 'colNA' if not specified. See ?ColorBar for a full explanation on 'col_inf' and 'col_sup'. +Colour identifiers to colour the values in 'var' that go beyond the extremes of the colour bar and to colour NA values, respectively. 'colNA' takes attr(cols, 'na_color') if available by default, where cols is the parameter 'cols' if provided or the vector of colors returned by 'color_fun'. If not available, it takes 'pink' by default. 'col_inf' and 'col_sup' will take the value of 'colNA' if not specified. See ?ColorBar for a full explanation on 'col_inf' and 'col_sup'. } \item{color_fun,subsampleg,bar_extra_labels,draw_bar_ticks,draw_separators,triangle_ends_scale,bar_label_digits,bar_label_scale,units_scale,bar_tick_scale,bar_extra_margin}{ Set of parameters to control the visual aspect of the drawn colour bar. See ?ColorBar for a full explanation. diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index fe197eee2423049ff1fc5290df15fb2d5a185c34..8b262b7f61654c85d9a6b3d19b19118efacacda3 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -11,7 +11,7 @@ PlotStereoMap(var, lon, lat, latlims = c(60, 90), toptitle = NULL, sizetit = NULL, units = NULL, brks = NULL, cols = NULL, bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - colNA = 'white', color_fun = clim.colors, + colNA = NULL, color_fun = clim.palette(), filled.continents = FALSE, coast_color = NULL, coast_width = 1, dots = NULL, dot_symbol = 4, dot_size = 0.8, @@ -55,7 +55,7 @@ Title at the top of the colour bar, most commonly the units of the variable prov Usually only providing 'brks' is enough to generate the desired colour bar. These parameters allow to define n breaks that define n - 1 intervals to classify each of the values in 'var'. The corresponding grid cell of a given value in 'var' will be coloured in function of the interval it belongs to. These parameters are sent to \code{ColorBar()} to generate the breaks and colours. Additional colours for values beyond the limits of the colour bar are also generated and applied to the plot if 'bar_limits' or 'brks' and 'triangle_ends' are properly provided to do so. See ?ColorBar for a full explanation.\cr } \item{col_inf,col_sup,colNA}{ -Colour identifiers to colour the values in 'var' that go beyond the extremes of the colour bar and to colour NA values, respectively. 'colNA' takes 'white' by default. 'col_inf' and 'col_sup' will take the value of 'colNA' if not specified. See ?ColorBar for a full explanation on 'col_inf' and 'col_sup'. +Colour identifiers to colour the values in 'var' that go beyond the extremes of the colour bar and to colour NA values, respectively. 'colNA' takes attr(cols, 'na_color') if available by default, where cols is the parameter 'cols' if provided or the vector of colors returned by 'color_fun'. If not available, it takes 'pink' by default. 'col_inf' and 'col_sup' will take the value of 'colNA' if not specified. See ?ColorBar for a full explanation on 'col_inf' and 'col_sup'. } \item{color_fun,subsampleg,bar_extra_labels,draw_bar_ticks,draw_separators,triangle_ends_scale,bar_label_digits,bar_label_scale,units_scale,bar_tick_scale,bar_extra_margin}{ Set of parameters to control the visual aspect of the drawn colour bar. See ?ColorBar for a full explanation. diff --git a/man/clim.colors.Rd b/man/clim.colors.Rd deleted file mode 100644 index 8d61dad9e2684a4637744784943c4010d0cd26ec..0000000000000000000000000000000000000000 --- a/man/clim.colors.Rd +++ /dev/null @@ -1,27 +0,0 @@ -\name{clim.colors} -\alias{clim.colors} -\title{Generate Climate Color Bar} -\description{ -Generates a color bar with color ranges useful in climate temperature variable plotting.\cr -The original colors are:\cr - c("dodgerblue4", "dodgerblue1", "forestgreen", "yellowgreen", "white",\cr - "white", "yellow", "orange", "red", "saddlebrown") -} -\usage{ -clim.colors(n) -} -\arguments{ - \item{n}{ -Number of colors to generate. - } -} -\examples{ -cols <- clim.colors(20) -lims <- seq(-1, 1, length.out = 21) -ColorBar(lims, cols) -} -\author{ -History:\cr -0.0 - 2016-01 (N. Manubens, \email{nicolau.manubens at bsc.es}) - Original code.\cr -} -\keyword{datagen} diff --git a/man/clim.palette.Rd b/man/clim.palette.Rd new file mode 100644 index 0000000000000000000000000000000000000000..b82a5efdb03957bbc35e0a7e0e85cf77272992de --- /dev/null +++ b/man/clim.palette.Rd @@ -0,0 +1,33 @@ +\name{clim.palette} +\alias{clim.colors} +\alias{clim.palette} +\title{Generate Climate Color Palettes} +\description{ +Generates a colorblind friendly color palette with color ranges useful in climate temperature variable plotting.\cr +} +\usage{ +clim.palette(palette = 'bluered') + +clim.colors(n, palette = 'bluered') +} +\arguments{ + \item{palette}{ +Which type of palette to generate: from blue through white to red ('bluered'), from red through white to blue ('redblue'), from yellow through orange to red ('yellowred'), or from red through orange to red ('redyellow'). + } + \item{n}{ +Number of colors to generate. + } +} +\examples{ +lims <- seq(-1, 1, length.out = 21) + +ColorBar(lims, color_fun = clim.palette('redyellow')) + +cols <- clim.colors(20) +ColorBar(lims, cols) +} +\author{ +History:\cr +0.0 - 2016-01 (N. Manubens, \email{nicolau.manubens at bsc.es}) - Original code.\cr +} +\keyword{datagen}