R包:ggsci期刊配色

介绍

不同期刊配色大多数时候不一样,为了更好符合期刊图片颜色的配色,有人开发了ggsci这个R包。它提供以下函数:

  • scale_color_palname()

  • scale_fill_palname()

对应不同期刊的color和fill函数。

导入数据+R包

R 复制代码
library("ggsci")
library("ggplot2")
library("gridExtra")

data("diamonds")

p1 <- ggplot(subset(diamonds, carat >= 2.2),
       aes(x = table, y = price, colour = cut)) +
       geom_point(alpha = 0.7) +
      geom_smooth(method = "loess", alpha = 0.05, size = 1, span = 1) +
      theme_bw()

p2 <-  ggplot(subset(diamonds, carat > 2.2 & depth > 55 & depth < 70),
          aes(x = depth, fill = cut)) +
          geom_histogram(colour = "black", binwidth = 1, position = "dodge") +
          theme_bw()

NPG: Nature Publishing Group

R 复制代码
p1_npg <- p1 + scale_color_npg()
p2_npg <- p2 + scale_fill_npg()
grid.arrange(p1_npg, p2_npg, ncol = 2)

AAAS: American Association for the Advancement of Science

R 复制代码
p1_aaas <- p1 + scale_color_aaas()
p2_aaas <- p2 + scale_fill_aaas()
grid.arrange(p1_aaas, p2_aaas, ncol = 2)

NEJM:The New England Journal of Medicine

R 复制代码
p1_nejm <- p1 + scale_color_nejm()
p2_nejm <- p2 + scale_fill_nejm()
grid.arrange(p1_nejm, p2_nejm, ncol = 2)

Lancet: Lancet journals

R 复制代码
p1_lancet <- p1 + scale_color_lancet()
p2_lancet <- p2 + scale_fill_lancet()
grid.arrange(p1_lancet, p2_lancet, ncol = 2)
JAMA: The Journal of the American Medical Association
R 复制代码
p1_jama <- p1 + scale_color_jama()
p2_jama <- p2 + scale_fill_jama()
grid.arrange(p1_jama, p2_jama, ncol = 2)

UCSCGB: UCSC Genome Browser

R 复制代码
p1_ucscgb <- p1 + scale_color_ucscgb()
p2_ucscgb <- p2 + scale_fill_ucscgb()
grid.arrange(p1_ucscgb, p2_ucscgb, ncol = 2)

Tron Legacy

R 复制代码
p1_tron <- p1 + theme_dark() + theme(
    panel.background = element_rect(fill = "#2D2D2D"),
    legend.key = element_rect(fill = "#2D2D2D")) +
  scale_color_tron()
p2_tron <- p2 + theme_dark() + theme(
    panel.background = element_rect(fill = "#2D2D2D")) +
  scale_fill_tron()
grid.arrange(p1_tron, p2_tron, ncol = 2)

GSEA: GSEA GenePattern

R 复制代码
library("reshape2")

data("mtcars")
cor <- cor(unname(cbind(mtcars, mtcars, mtcars, mtcars)))
cor_melt <- melt(cor)

p3 <- ggplot(cor_melt, aes(x = Var1, y = Var2, fill = value)) +
  geom_tile(colour = "black", size = 0.3) +
  theme_bw() +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank())

p3_gsea <- p3 + scale_fill_gsea()
p3_gsea_inv <- p3 + scale_fill_gsea(reverse = TRUE)
grid.arrange(p3_gsea, p3_gsea_inv, ncol = 2)

Reference

  1. ggsci
相关推荐
捷码小编43 分钟前
如何选择专业数据可视化开发工具?为您拆解捷码全功能和落地指南!
低代码·数字孪生·数据可视化
善木科研21 小时前
读文献先读图:GO弦图怎么看?
机器学习·数据分析·r语言
Tiger Z1 天前
R 语言科研绘图第 55 期 --- 网络图-聚类
开发语言·r语言·贴图
十三画者1 天前
【数据分析】R版IntelliGenes用于生物标志物发现的可解释机器学习
python·机器学习·数据挖掘·数据分析·r语言·数据可视化
搏博2 天前
将图形可视化工具的 Python 脚本打包为 Windows 应用程序
开发语言·windows·python·matplotlib·数据可视化
lishaoan774 天前
实验设计与分析(第6版,Montgomery著,傅珏生译) 第10章拟合回归模型10.9节思考题10.12 R语言解题
回归·r语言·线性回归·残差分析·实验设计与数据分析·回归显著性
南瓜胖胖4 天前
【R语言编程绘图-mlbench】
开发语言·机器学习·r语言
天桥下的卖艺者4 天前
R语言使用随机过采样(Random Oversampling)平衡数据集
开发语言·r语言
@HNUSTer4 天前
Python数据可视化科技图表绘制系列教程(一)
python·数据可视化·科技论文·专业制图·科研图表
Biomamba生信基地5 天前
R语言基础| 创建数据集
开发语言·r语言·生信·医药