你可以尝试一下randomcoloR https://github.com/ronammar/randomcoloR(最多 40 种不同的颜色)或pals https://cran.r-project.org/web/packages/pals/vignettes/pals_examples.html(最多 26 种颜色)。
# k: number of colors (>= 1). May be ineffective for k > 40.
library(randomcoloR)
nColor <- 40
myColor <- randomcoloR::distinctColorPalette(k = 40)
pie(rep(1, nColor), col = myColor)
# https://cran.r-project.org/web/packages/pals/vignettes/pals_examples.html
library(pals)
labs = c('alphabet', 'alphabet2', 'glasbey', 'kelly', 'polychrome')
op = par(mar = c(0, 5, 3, 1))
pal.bands(alphabet(), alphabet2(), glasbey(), kelly(), polychrome(),
labels = labs, show.names = FALSE)
创建于 2018-05-13代表包 http://reprex.tidyverse.org(v0.2.0)。