diff --git a/modules/Scorecards/R/tmp/ColorBarContinuous.R b/modules/Scorecards/R/tmp/ColorBarContinuous.R index a4ef933fe032cf60a22e992e1bcae175b79d4961..803e3301550e578d74c120affcb1d4ce730c273c 100644 --- a/modules/Scorecards/R/tmp/ColorBarContinuous.R +++ b/modules/Scorecards/R/tmp/ColorBarContinuous.R @@ -157,7 +157,7 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, 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)) { @@ -170,14 +170,14 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, brks <- reorder$x } } - + # 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)) { if (!(is.numeric(var_limits) && (length(var_limits) == 2))) { @@ -188,7 +188,7 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, stop("Parameter 'var_limits' must not contain infinite values.") } } - + # Check cols if (!is.null(cols)) { if (!is.character(cols)) { @@ -197,12 +197,12 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, stop("Parameter 'cols' must contain valid colour identifiers.") } } - + # 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)) { @@ -248,22 +248,22 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, 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)) { stop("Parameter 'col_inf' must be a valid colour identifier.") } } - + # Check col_sup if (!is.null(col_sup)) { if (!.IsColor(col_sup)) { stop("Parameter 'col_sup' must be a valid colour identifier.") } } - + # 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.") @@ -291,18 +291,18 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, } } if (plot && !is.null(var_limits)) { - 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 ((bar_limits[1] > var_limits[1]) && !triangle_ends[1]) { + warning("There are variable values smaller than 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 ((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.") + "of the colour bar and the higher triangle end has been ", + "disabled. These will be painted in the colour for NA values.") } } - + # Generate colours if needed if (is.null(cols)) { cols <- color_fun(length(brks) - 1 + sum(triangle_ends)) @@ -319,12 +319,12 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, } 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 if (!is.logical(vertical)) { stop("Parameter 'vertical' must be TRUE or FALSE.") } - + # Check extra_labels if (is.null(extra_labels)) { extra_labels <- numeric(0) @@ -337,7 +337,7 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, } } extra_labels <- sort(extra_labels) - + # Check subsampleg primes <- function(x) { # Courtesy of Chase. See http://stackoverflow.com/questions/6424856/r-function-for-returning-all-factors @@ -372,27 +372,27 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, if ((subsampleg) < 1) { draw_labels <- FALSE } - + # Check plot if (!is.logical(plot)) { stop("Parameter 'plot' must be logical.") } - + # Check draw_separators if (!is.logical(draw_separators)) { stop("Parameter 'draw_separators' must be logical.") } - + # Check triangle_ends_scale if (!is.numeric(triangle_ends_scale)) { stop("Parameter 'triangle_ends_scale' must be numeric.") } - + # Check draw_ticks if (!is.logical(draw_ticks)) { stop("Parameter 'draw_ticks' must be logical.") } - + # Check title if (is.null(title)) { title <- '' @@ -400,38 +400,38 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, if (!is.character(title)) { stop("Parameter 'title' must be a character string.") } - + # Check title_scale if (!is.numeric(title_scale)) { stop("Parameter 'title_scale' must be numeric.") } - + # Check label_scale if (!is.numeric(label_scale)) { stop("Parameter 'label_scale' must be numeric.") } - + # Check tick_scale if (!is.numeric(tick_scale)) { stop("Parameter 'tick_scale' must be numeric.") } - + # Check extra_margin if (!is.numeric(extra_margin) || length(extra_margin) != 4) { stop("Parameter 'extra_margin' must be a numeric vector of length 4.") } - + # Check label_digits if (!is.numeric(label_digits)) { stop("Parameter 'label_digits' must be numeric.") } label_digits <- round(label_digits) - + # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "col", "lab", "las", "mar", "mgp", "new", "ps") userArgs <- .FilterUserGraphicArgs(excludedArgs, ...) - + # # Plotting colorbar # ~~~~~~~~~~~~~~~~~~~ @@ -448,8 +448,8 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, if (vertical) { figure_size <- rev(figure_size) } - # pannel_to_redraw <- par('mfg') - # .SwitchToFigure(pannel_to_redraw[1], pannel_to_redraw[2]) +# pannel_to_redraw <- par('mfg') +# .SwitchToFigure(pannel_to_redraw[1], pannel_to_redraw[2]) # Load the user parameters par(new = TRUE) par(userArgs) @@ -470,7 +470,7 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, margins[3] <- margins[3] + (1.0 * cex_title) * cs } margins[3] <- margins[3] + sqrt(figure_size[2] / (margins[1] + margins[3])) * - figure_size[2] / 6 * ifelse(title != '', 0.5, 0.8) + figure_size[2] / 6 * ifelse(title != '', 0.5, 0.8) # Set side margins margins[2] <- margins[2] + figure_size[1] / 16 margins[4] <- margins[4] + figure_size[1] / 16 @@ -535,7 +535,7 @@ ColorBarContinuous <- function(brks = NULL, cols = NULL, vertical = TRUE, lines(right_triangle$x, right_triangle$y) } par(xpd = FALSE) - + # Put the separators if (vertical) { if (draw_separators) {