Skip to content

Commit

Permalink
Fix comparing multiple values in a custom palette to palette names
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardJActon authored Mar 18, 2022
1 parent f7421cf commit b18385c
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions R/universal_colour_scaler.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,34 +155,38 @@ universal_colour_scaler <- function(
"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8})$",
palette, perl = TRUE
)
if(palette %in% viridis_pals) {
warning(
paste0(
"Looks like you specified a viridis palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: viridis"
if(length(palette) == 1) {
if(palette %in% viridis_pals) {
warning(
paste0(
"Looks like you specified a viridis palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: viridis"
)
)
)
type <- "viridis"
} else if (palette %in% scico_pals) {
warning(
paste0(
"Looks like you specified a scico palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: scico"
type <- "viridis"
} else if (palette %in% scico_pals) {
warning(
paste0(
"Looks like you specified a scico palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: scico"
)
)
)
type <- "scico"
} else if (palette %in% brewer_pals) {
warning(
paste0(
"Looks like you specified a scico palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: scico"
type <- "scico"
} else if (palette %in% brewer_pals) {
warning(
paste0(
"Looks like you specified a scico palette (", palette,
") with the type 'custom' and not a vector of custom ",
"hex codes!\n DFAULTING TO type: scico"
)
)
)
type <- "brewer"
} else if (all(palettelg)) {
type <- "brewer"
}
}

if (all(palettelg)) {
colours <- palette
} else { #if(!all(palettelg)) {
stop(
Expand Down

0 comments on commit b18385c

Please sign in to comment.