Skip to content

Commit

Permalink
fix for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
kassambara committed Apr 22, 2017
1 parent 9cccb0c commit e310202
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ NULL
ggplot2::scale_color_grey(..., start = 0.8, end = 0.2)
else if (palette == "hue")
ggplot2::scale_color_hue(...)
else if(.is_color(palette))
ggplot2::scale_color_manual(..., values = palette)
}
else if (palette[1] != "")
ggplot2::scale_color_manual(..., values = palette)
Expand Down Expand Up @@ -807,6 +809,15 @@ p
max(length(cols), length(fills))
}

# Check if character string is a valid color representation
.is_color <- function(x) {
sapply(x, function(X) {
tryCatch(is.matrix(grDevices::col2rgb(X)),
error = function(e) FALSE)
})
}





Expand Down

0 comments on commit e310202

Please sign in to comment.