I need to plot a line chart that has more than 50 different lines. I am using RColorBrewer to generate 50 unique colors to plot it. However some of the generated colors are very hard to read (e.g. bright yellow). Is there anyway to generate a set of colors that are easier to read?
library(tidyverse)
library(RColorBrewer)
library(plotly)
colors_ = colorRampPalette(brewer.pal(10,"Spectral"))(50)
grps = sort(rep(c(1:50),2)) %>% as.character() %>% unique
dat = data.frame(x = rep(c(1,2),50) , y = sort(rep(c(1:50),2)) , grp =as.character(sort(rep(c(1:50),2))) )
p = plot_ly(dat ,type = 'scatter', mode = 'lines')
for (i in 1:50){
p <- p %>% add_trace(data = filter(dat , grp ==grps[i] ) , x = ~x, y=~y,
line = list(color = colors_[i]),
text = grps[i]
)
}
p