1.前言
最近忙里偷闲,捣鼓一下配色,把童年回忆里的动漫都搬进来,给科研信仰充值吧~
提取颜色之前写过一个Py的,那个很准确不过调参会有点麻烦。这里分享一个比较懒人点的R包吧,虽然会有一定误差,但是无伤大雅——colorfindr
Github:https://github.com/zumbov2/colorfindr
2.模拟数据
以下多色系用模拟数据柱状图和某个单细胞UMAP作可视化
> data <- data.frame(
+ Category = paste("Category", 1:15),
+ Value = sample(10:100, 15)
+ )
# > str(data)
# 'data.frame': 15 obs. of 2 variables:
# $ Category: chr "Category 1" "Category 2" "Category 3" "Category 4" ...
# $ Value : int 22 59 73 42 33 18 40 75 94 69 ...
3. 16色
3.1 主角团
> newcol[1] "#0C0E0B" "#FFFEFF" "#0B1225" "#12151A" "#9E93A1" "#121548" "#300000" "#832E19" "#FFEAB1"
[10] "#0C129A" "#1B557D" "#CBDDE9" "#B3271A" "#DC7B06" "#E5A366" "#1A64EB"
3.2 世界种子交叉
> newcol[1] "#1A50AA" "#5398CF" "#6DA7CF" "#397ABA" "#94BFE2" "#598BAC" "#FBFFFF" "#B1D5ED" "#507298"
[10] "#314D75" "#90C158" "#8F9490" "#D6D0C0" "#9BCD5E" "#203554" "#50763D"
3.3 爱丽丝
> newcol[1] "#FEFEFE" "#012241" "#FBF465" "#00316B" "#C9B96C" "#B8BAAC" "#F0B589" "#EDE55C" "#194BC4"
[10] "#9C5C1E" "#322A5D" "#B89146" "#FAFF98" "#FFFFCC" "#FD8725" "#616163"
3.4 诗乃
> newcol[1] "#000000" "#000018" "#003658" "#FFFDF0" "#002820" "#013B60" "#00469E" "#0081D5" "#252D2F"
[10] "#00CDEC" "#004FAB" "#00689F" "#0198DD" "#75FFFF" "#A08F95" "#897286"
3.5 绝剑
> newcol[1] "#FFFFFF" "#2C1F29" "#2A1D27" "#FFCBFF" "#6C3F46" "#78094E" "#C869A1" "#4A0000" "#E4A56F"
[10] "#92615C" "#CBB4BE" "#C72E89" "#BB784D" "#E947B7" "#7D6244" "#B70000"
3.6 尤吉欧
> newcol[1] "#FEFEFE" "#1B4B7C" "#F8ECDC" "#F4F4F6" "#E1E5F1" "#063470" "#B8D2F7" "#B68C5C" "#81ABE7"
[10] "#7DA9E6" "#2573D7" "#215DCB" "#5B80D1" "#D6B067" "#388EF3" "#92A5B3"
4.R包提取颜色
install.packages("colorfindr")
library("colorfindr")> list.files(pattern = "alice")
# [1] "anime-sword-art-online-alicization-kirito-sword-art-online-kirigaya-kazuto-alice-sword-art-online-alicization-hd-wallpaper-preview.jpg"> ## 提取颜色
> color <- get_colors("anime-sword-art-online-alicization-kirito-sword-art-online-kirigaya-kazuto-alice-sword-art-online-alicization-hd-wallpaper-preview.jpg") %>%
+ make_palette(n = 12)
> color[1] "#FEFEFE" "#012241" "#FBF465" "#C9B96C" "#B8BAAC" "#EDE55C" "#194BC4" "#9C5C1E"[9] "#322A5D" "#B89146" "#FAFF98" "#AA7D5C"
> scales::show_col(color)
其他可视化:
## RGB的3d可视化
get_colors("anime-sword-art-online-alicization-kirito-sword-art-online-kirigaya-kazuto-alice-sword-art-online-alicization-hd-wallpaper-preview.jpg") %>%
plot_colors_3d(sample_size = 5000, marker_size = 2.5, color_space = "RGB")
## HSV的3d可视化
get_colors("anime-sword-art-online-alicization-kirito-sword-art-online-kirigaya-kazuto-alice-sword-art-online-alicization-hd-wallpaper-preview.jpg") %>%
plot_colors_3d(sample_size = 5000, marker_size = 2.5, color_space = "HSV")
5.小总结
好的配色第一印象不一样,看着心情都不一样,真的,杜绝红蓝配色了吧,最近审稿还是看到不少红蓝、红绿,极度审美疲劳了