diff --git a/NEWS.md b/NEWS.md index bba978e4..6c79f173 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * flea is now standardised measurements, and flea_raw is the original units * TeachingDemos removed as a Suggests, and replaced with aplpack for drawing Chernoff faces * addition of a pre-specified ellipse can be added to the 2D display +* palette can now be a vector of values # tourr 1.1.0 diff --git a/R/util.r b/R/util.r index c2290cd4..dce0ea12 100644 --- a/R/util.r +++ b/R/util.r @@ -122,7 +122,14 @@ areColors <- function(x) { #' @export mapColors <- function(x, palette) { n <- length(unique(x)) - pal <- grDevices::hcl.colors(n, palette=palette) + # Handle manual colour setting + if (length(palette) > 1) { + stopifnot(length(palette) == n) + pal <- palette + } + else { + pal <- grDevices::hcl.colors(n, palette=palette) + } pal[as.numeric(as.factor(x))] }