Tech、Food & Life

  • 首页
  • 软件下载
    • 电脑和软件
    • Mac软件
    • windows软件
  • Telegram电报
  • 网站资源推荐
  • 海外流媒体
    • netflix
    • Youtube
    • Disney+
    • HBO
  • 生活日常
    • COVID19疫情相关
    • 德国驾照和车
    • 电脑和软件
    • 花花草草
  • 烘焙
  • 关于我
  • 中EN
Tech Food & Life
爱技术,爱美食,爱生活
  1. Home
  2. English Articles
  3. Article

5 ggplot2 Color Schemes for Scientific Papers with R Code

2026年6月3日 1点热度 0人点赞 0条评论
Language: 🇨🇳 中文版 🇬🇧 English

Good figure design is half about color. Scientific figures have extra requirements: readable by colorblind readers, distinguishable in grayscale print, and meeting journal resolution standards. Below are 5 practical schemes I accumulated while writing papers, each with complete R code.

Why not use ggplot2 default colors?

ggplot2's default rainbow color wheel has two major flaws: red-green colorblind people cannot distinguish them (about 8% of men globally), and when printed in grayscale, the brightness differences between colors are minimal, making them nearly indistinguishable. These issues appear in reviewer comments far more often than you'd expect.

Scheme 1: viridis (colorblind-safe + gradient first choice)

library(viridis)
library(ggplot2)

# Continuous variable (e.g., heatmap)
ggplot(df, aes(x, y, fill=value)) +
  geom_tile() +
  scale_fill_viridis_c()

# Discrete variable
ggplot(df, aes(x, y, color=group)) +
  geom_point() +
  scale_color_viridis_d(option="D") # also "magma", "plasma"

viridis is currently the most common color scheme in Nature and Science sub-journals. It is colorblind-safe and has clear layering in grayscale.

Scheme 2: ColorBrewer (first choice for categorical variables)

scale_color_brewer(palette = "Set2")   # 8 colors, soft
scale_color_brewer(palette = "Dark2")  # 8 colors, dark version
scale_fill_brewer(palette  = "Blues")  # single-hue gradient

At colorbrewer2.org you can preview all palettes and filter by "Colorblind safe".

Scheme 3: ggsci journal palettes

library(ggsci)
scale_color_nejm()     # NEJM style: blue, red, black
scale_color_lancet()   # Lancet style
scale_color_jco()      # JCO style (oncology journal)
scale_color_npg()      # Nature series

When submitting to life science journals, using the corresponding journal's color style makes reviewers feel at home and creates a more unified visual appearance.

Scheme 4: Manual definition (most controllable)

# Pick 4 colors (tune with Adobe Color or coolors.co)
my_colors <- c("#E64B35", "#4DBBD5", "#00A087", "#3C5488")

scale_color_manual(values = my_colors)
scale_fill_manual(values  = my_colors)

The advantage is that all figures use exactly the same colors, giving your paper the strongest visual consistency.

Scheme 5: Colorblind check before submission

install.packages("colorblindr")
library(colorblindr)

p <- ggplot(df, aes(x, y, color=group)) + geom_point()
cvd_grid(p)  # simulates red-green + blue-yellow colorblindness + grayscale, 4 views

Run this before submission to confirm that groups are still distinguishable under colorblind vision. This step can prevent reviewers from specifically pointing out "Figure X is not colorblind-friendly."

标签: 暂无
最后更新:2026年6月3日

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

Latest Popular Random
Latest Popular Random
德国求职信(Anschreiben)怎么写:格式规范与正文结构详解 德国 Bio 有机产品值不值得买:哪些食物优先选有机,在哪里买最省 德国学生餐厅(Mensa)完全指南:价格、菜单、付款和全国特色 穷游瑞士:从德国出发 5 天 500 欧的可行路线 Notion + Obsidian 管理博士/硕士科研笔记:知识库搭建方案 在德国复刻中式早餐:豆浆、油条和葱油饼在家怎么做
ggplot2 科研配色方案:5 套可直接用的代码单细胞测序入门:Seurat 完整流程(raw counts → UMAP)全注释德国面粉 Type 405/550/1050 区别:对应中国低筋/中筋/高筋粉的换算在德国做中式面食:食材替代方案和必去亚洲超市攻略德国黄油烘焙指南:Süßrahm vs Sauerrahm、脂肪含量和温度处理德国硕士申请全流程:Uni-Assist 注册、材料提交和 NC 判断
上海+7酒店清单以及夫妻同住问题解答 在线看各地报纸和直播,转自老生常谈 2021 最新回国隔离政策 被父母断供怎么办:德国留学生的财务自救方案 在德公派博士生保险的选择 德国境内转账和向国内汇款:SEPA、Wise、银行电汇怎么选
Tags
windows 破解 4k Netflix mac 下载 奈飞 在线

COPYRIGHT © 2020-2025 SUNQI.ORG ALL RIGHTS RESERVED. 本站部分资源来源于网络,如有侵权请联系删除,谢谢。

Theme Kratos Made By Seaton Jiang