一、颜色包
1) wesanderson
install.packages("wesanderson")
library("wesanderson")
#See all palettes
names(wes_palettes)
[1] "BottleRocket1" "BottleRocket2" "Rushmore1" "Rushmore"
[5] "Royal1" "Royal2" "Zissou1" "Darjeeling1"
[9] "Darjeeling2" "Chevalier1" "FantasticFox1" "Moonrise1"
[13] "Moonrise2" "Moonrise3" "Cavalcanti1" "GrandBudapest1"
[17] "GrandBudapest2" "IsleofDogs1" "IsleofDogs2"
展示:
name_list=names(wes_palettes)
par(mfrow=c(5,4))
for (i in 1:length(name_list)) {
p=wes_palette(name_list[i]);
print(p);
}
使用
wes_palette("Zissou1")
colors=wes_palette("Zissou1", 100, type = "continuous")
scale_fill_gradientn(colours = colors)
2) ggsci
library(ggsci)
scale_color_palname()
scale_fill_palname()
Name | Scales | Palette Types | Palette Generator |
---|---|---|---|
NPG | scale_color_npg(); scale_fill_npg() | "nrc" | :pal_npg() |
AAAS | scale_color_aaas(); scale_fill_aaas() | "default" | pal_aaas() |
NEJM | scale_color_nejm(); scale_fill_nejm() | "default" | pal_nejm() |
Lancet | scale_color_lancet(); scale_fill_lancet() | "lanonc" | pal_lancet() |
JAMA | scale_color_jama(); scale_fill_jama() | "default" | pal_jama() |
JCO | scale_color_jco(); scale_fill_jco() | "default" | pal_jco() |
UCSCGB | scale_color_ucscgb(); scale_fill_ucscgb() | "default" | pal_ucscgb() |
D3 | scale_color_d3(); scale_fill_d3() | "category10"; "category20"; "category20b"; "category20c" | pal_d3() |
LocusZoom | scale_color_locuszoom() scale_fill_locuszoom() | "default" | pal_locuszoom() |
IGV | scale_color_igv() scale_fill_igv() | "default"; "alternating" | pal_igv() |
UChicago | scale_color_uchicago() scale_fill_uchicago() | "default"; "light"; "dark" | pal_uchicago() |
Star Trek | scale_color_startrek() scale_fill_startrek() | "uniform" | pal_startrek() |
Tron Legacy | scale_color_tron() scale_fill_tron() | "legacy" | pal_tron() |
Futurama | scale_color_futurama() scale_fill_futurama() | "planetexpress" | pal_futurama() |
Rick and Morty | scale_color_rickandmorty() scale_fill_rickandmorty() | "schwifty" | pal_rickandmorty() |
The Simpsons | scale_color_simpsons() scale_fill_simpsons() | "springfield" | pal_simpsons() |
GSEA | scale_color_gsea() scale_fill_gsea() | "default" | pal_gsea() |
Material Design | scale_color_material() scale_fill_material() | "red" "pink"; "purple" "deep-purple"; "indigo" "blue"; "light-blue" "cyan"; "teal" "green"; "light-green" "lime"; "yellow" "amber"; "orange" "deep-orange"; "brown" "grey"; "blue-grey" | pal_material() |
展示
library("scales")
par(mfrow=c(5,5))
show_col(pal_aaas("default")(10))
show_col(pal_d3("category10")(10))
show_col(pal_d3("category20")(10))
show_col(pal_d3("category20b")(10))
show_col(pal_d3("category20c")(10))
show_col(pal_futurama("planetexpress")(12))
show_col(pal_gsea("default")(12))
show_col(pal_igv("default")(51))
show_col(pal_igv("alternating")(2))
show_col(pal_jama("default")(7))
show_col(pal_jco("default")(10))
show_col(pal_lancet("lanonc")(9))
show_col(pal_locuszoom("default")(7))
show_col(pal_material("indigo")(10))
#"red","pink","purple","deep-purple","indigo","blue","light-blue","cyan","teal","green","light-green","lime","yellow","amber","orange",,"deep-orange","brown","grey","blue-grey"
show_col(pal_nejm("default")(8))
show_col(pal_npg("nrc")(10))
show_col(pal_rickandmorty("schwifty")(12))
show_col(pal_simpsons("springfield")(16))
show_col(pal_startrek("uniform")(7))
show_col(pal_tron("legacy")(7))
show_col(pal_uchicago("default")(9))
show_col(pal_uchicago("light")(9))
show_col(pal_uchicago("dark")(9))
show_col(pal_ucscgb("default")(26))
show_col(pal_gsea("default")(12))
3)RColorBrewer
library(RColorBrewer)
display.brewer.all()
用法
col=brewer.pal(8,"Set3")
4) randomcoloR
library(randomcoloR)
palette <- randomColor(count = 60) #随机生成60种颜色,其实里面有重复的
palette <- distinctColorPalette(60) #差异明显的60种
5) 自定义
到这里随便用https://www.sojson.com/rgb.html
color_list=c("#ed1299", "#09f9f5", "#246b93", "#cc8e12", "#d561dd", "#c93f00", "#ddd53e", "#4aef7b", "#e86502", "#9ed84e", "#39ba30", "#6ad157", "#8249aa", "#99db27", "#e07233", "#ff523f", "#ce2523", "#f7aa5d", "#cebb10", "#03827f", "#931635", "#373bbf", "#a1ce4c", "#ef3bb6", "#d66551","#1a918f", "#ff66fc", "#2927c4", "#7149af" ,"#57e559" ,"#8e3af4" ,"#f9a270" ,"#22547f", "#db5e92","#edd05e", "#6f25e8", "#0dbc21", "#280f7a", "#6373ed", "#5b910f" ,"#7b34c1" ,"#0cf29a" ,"#d80fc1","#dd27ce", "#07a301", "#167275", "#391c82", "#2baeb5","#925bea", "#63ff4f")