Skip to content

Commit

Permalink
fix randomness in distinct colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajic authored Nov 24, 2023
1 parent a9cb15b commit 64052fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/color_palettes.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ getDistinctColors <- function(n) {
admitted_grey_colors = grey_colors[seq(1, 110, 10)]
broad_colors = c(all_colors_no_grey, admitted_grey_colors)

# if too many colors warn about recycling
set.seed(1234)
on.exit(set.seed(Sys.time()))
# if too many colors requested, warn about recycling
if(n > length(broad_colors)) {
warning('\n not enough unique colors in R, maximum = 444 \n')
set.seed(1234)
on.exit(set.seed(Sys.time()))
col_vector = sample(x = broad_colors, size = n, replace = TRUE)
} else {
col_vector = sample(x = broad_colors, size = n, replace = FALSE)
Expand Down

0 comments on commit 64052fe

Please sign in to comment.