R包Colorfindr识别图片颜色|用刀剑神域方式打开SCI科研配色

1.前言

最近忙里偷闲,捣鼓一下配色,把童年回忆里的动漫都搬进来,给科研信仰充值吧~

提取颜色之前写过一个Py的,那个很准确不过调参会有点麻烦。这里分享一个比较懒人点的R包吧,虽然会有一定误差,但是无伤大雅------colorfindr

Github:https://github.com/zumbov2/colorfindr

2.模拟数据

以下多色系用模拟数据柱状图和某个单细胞UMAP作可视化

r 复制代码
> 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 主角团

r 复制代码
> newcol
 [1] "#0C0E0B" "#FFFEFF" "#0B1225" "#12151A" "#9E93A1" "#121548" "#300000" "#832E19" "#FFEAB1"
[10] "#0C129A" "#1B557D" "#CBDDE9" "#B3271A" "#DC7B06" "#E5A366" "#1A64EB"

3.2 世界种子交叉

r 复制代码
> newcol
 [1] "#1A50AA" "#5398CF" "#6DA7CF" "#397ABA" "#94BFE2" "#598BAC" "#FBFFFF" "#B1D5ED" "#507298"
[10] "#314D75" "#90C158" "#8F9490" "#D6D0C0" "#9BCD5E" "#203554" "#50763D"

3.3 爱丽丝

r 复制代码
> newcol
 [1] "#FEFEFE" "#012241" "#FBF465" "#00316B" "#C9B96C" "#B8BAAC" "#F0B589" "#EDE55C" "#194BC4"
[10] "#9C5C1E" "#322A5D" "#B89146" "#FAFF98" "#FFFFCC" "#FD8725" "#616163"

3.4 诗乃

r 复制代码
> newcol
 [1] "#000000" "#000018" "#003658" "#FFFDF0" "#002820" "#013B60" "#00469E" "#0081D5" "#252D2F"
[10] "#00CDEC" "#004FAB" "#00689F" "#0198DD" "#75FFFF" "#A08F95" "#897286"

3.5 绝剑

r 复制代码
> newcol
 [1] "#FFFFFF" "#2C1F29" "#2A1D27" "#FFCBFF" "#6C3F46" "#78094E" "#C869A1" "#4A0000" "#E4A56F"
[10] "#92615C" "#CBB4BE" "#C72E89" "#BB784D" "#E947B7" "#7D6244" "#B70000"

3.6 尤吉欧

r 复制代码
> newcol
 [1] "#FEFEFE" "#1B4B7C" "#F8ECDC" "#F4F4F6" "#E1E5F1" "#063470" "#B8D2F7" "#B68C5C" "#81ABE7"
[10] "#7DA9E6" "#2573D7" "#215DCB" "#5B80D1" "#D6B067" "#388EF3" "#92A5B3"

4.R包提取颜色

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) 

其他可视化:

r 复制代码
## 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")
r 复制代码
## 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.小总结

好的配色第一印象不一样,看着心情都不一样,真的,杜绝红蓝配色 了吧,最近审稿还是看到不少红蓝红绿,极度审美疲劳了

相关推荐
blammmp7 分钟前
Java:数据结构-枚举
java·开发语言·数据结构
何曾参静谧20 分钟前
「C/C++」C/C++ 指针篇 之 指针运算
c语言·开发语言·c++
暗黑起源喵26 分钟前
设计模式-工厂设计模式
java·开发语言·设计模式
WaaTong30 分钟前
Java反射
java·开发语言·反射
Troc_wangpeng32 分钟前
R language 关于二维平面直角坐标系的制作
开发语言·机器学习
努力的家伙是不讨厌的33 分钟前
解析json导出csv或者直接入库
开发语言·python·json
Envyᥫᩣ1 小时前
C#语言:从入门到精通
开发语言·c#
童先生1 小时前
Go 项目中实现类似 Java Shiro 的权限控制中间件?
开发语言·go
lulu_gh_yu1 小时前
数据结构之排序补充
c语言·开发语言·数据结构·c++·学习·算法·排序算法
Re.不晚2 小时前
Java入门15——抽象类
java·开发语言·学习·算法·intellij-idea