查看: 1281|回复: 0

可视化配色方案直接抄!两套黑红系配色+两套蓝色系配色!!

[复制链接]

88

主题

26

回帖

58

日志

版主

积分
882
QQ
发表于 2024-6-1 11:59:56 | 显示全部楼层 |阅读模式 来自 中国
配色方案一

8827f9ac5eeccba33ff6fe59e45ea7ab.png

d83fb2dc23a7f387d60efc51a2bfebc3.png
作图数据跟代码:
  1. library(tidyverse)
  2. library(palmerpenguins)
  3. library(patchwork)


  4. pal = c("#000000", "#f5688a",  "#ffdfea")
  5. ## p1
  6. penguins %>%
  7.   ggplot() +
  8.   geom_density(aes(x=body_mass_g, fill=species),
  9.                alpha = 0.75) +
  10.   scale_x_continuous(limits = c(2000, 7000)) +
  11.   scale_fill_manual(values=pal, guide="none") +
  12.   theme(plot.margin = margin(10, 30, 10, 30))

  13. ## p2
  14. penguins %>%
  15.   ggplot() +
  16.   geom_point(aes(x=bill_length_mm, y=bill_depth_mm, fill=species),
  17.                size=2.5, shape=21, color = "black") +
  18.   scale_fill_manual(values=pal, guide="none") +
  19.   theme(plot.margin = margin(10, 30, 10, 30))

  20. ##p3
  21. penguins %>%
  22.   ggplot() +
  23.   geom_boxplot(aes(x=sex, y=bill_length_mm, fill=species)) +
  24.   scale_fill_manual(values=pal, guide="none") +
  25.   theme(plot.margin = margin(10, 30, 10, 30))

  26. ##p4
  27. penguins %>%
  28.   filter(!is.na(sex)) %>%
  29.   ggplot(aes(x=sex, y=bill_length_mm)) +
  30.   geom_bar(aes(fill=species),
  31.            stat = "summary", fun="mean",
  32.            color="black", width = 0.75, position = position_dodge()) +
  33.   # geom_jitter(size=2) +
  34.   scale_fill_manual(values=pal, guide="none") +
  35.   theme(plot.margin = margin(10, 30, 10, 30))

  36. ##p5
  37. data = read_csv("./data/误差棒图.csv")
  38. data %>%
  39.   mutate(upper = `Estimation coefficients` + SEM,
  40.          lower = `Estimation coefficients` - SEM) -> df


  41. ggplot(data = df) +
  42.   geom_errorbar(aes(x=Month, ymin=lower, ymax=upper),
  43.                 width = 0.25) +
  44.   geom_line(aes(x=Month, y=`Estimation coefficients`, color=group),
  45.             linewidth=1.75) +
  46.   geom_point(aes(x=Month, y=`Estimation coefficients`, fill=group),
  47.              shape=21, size=4.5) +
  48.   scale_fill_manual(values=pal, guide="none") +
  49.   scale_color_manual(values=pal, guide="none") +
  50.   theme(plot.margin = margin(10, 30, 10, 30))

  51. ##p6  
  52. penguins %>%
  53.   ggplot() +
  54.   geom_histogram(aes(x=body_mass_g, fill=species),
  55.                alpha = 0.75, color="black") +
  56.   scale_x_continuous(limits = c(2000, 7000)) +
  57.   scale_fill_manual(values=pal, guide="none") +
  58.   theme(plot.margin = margin(10, 30, 10, 30))
复制代码

2.配色方案二

0935b639c275fb1fe49bd9077e7d9ecd.png

fb1e9d79e2d25a4ba9cece50ca26c692.png
作图数据跟代码:

  1. library(tidyverse)
  2. library(palmerpenguins)
  3. library(patchwork)


  4. pal = c("#4464b9", "#23afe2",  "#8db8fd")
  5. ## p1
  6. penguins %>%
  7.   ggplot() +
  8.   geom_density(aes(x=body_mass_g, fill=species),
  9.                alpha = 0.75) +
  10.   scale_x_continuous(limits = c(2000, 7000)) +
  11.   scale_fill_manual(values=pal, guide="none") +
  12.   theme(plot.margin = margin(10, 30, 10, 30))

  13. ## p2
  14. penguins %>%
  15.   ggplot() +
  16.   geom_point(aes(x=bill_length_mm, y=bill_depth_mm, fill=species),
  17.                size=2.5, shape=21, color = "black") +
  18.   scale_fill_manual(values=pal, guide="none") +
  19.   theme(plot.margin = margin(10, 30, 10, 30))

  20. ##p3
  21. penguins %>%
  22.   ggplot() +
  23.   geom_boxplot(aes(x=sex, y=bill_length_mm, fill=species)) +
  24.   scale_fill_manual(values=pal, guide="none") +
  25.   theme(plot.margin = margin(10, 30, 10, 30))

  26. ##p4
  27. penguins %>%
  28.   filter(!is.na(sex)) %>%
  29.   ggplot(aes(x=sex, y=bill_length_mm)) +
  30.   geom_bar(aes(fill=species),
  31.            stat = "summary", fun="mean",
  32.            color="black", width = 0.75, position = position_dodge()) +
  33.   # geom_jitter(size=2) +
  34.   scale_fill_manual(values=pal, guide="none") +
  35.   theme(plot.margin = margin(10, 30, 10, 30))

  36. ##p5
  37. data = read_csv("./data/误差棒图.csv")
  38. data %>%
  39.   mutate(upper = `Estimation coefficients` + SEM,
  40.          lower = `Estimation coefficients` - SEM) -> df


  41. ggplot(data = df) +
  42.   geom_errorbar(aes(x=Month, ymin=lower, ymax=upper),
  43.                 width = 0.25) +
  44.   geom_line(aes(x=Month, y=`Estimation coefficients`, color=group),
  45.             linewidth=1.75) +
  46.   geom_point(aes(x=Month, y=`Estimation coefficients`, fill=group),
  47.              shape=21, size=4.5) +
  48.   scale_fill_manual(values=pal, guide="none") +
  49.   scale_color_manual(values=pal, guide="none") +
  50.   theme(plot.margin = margin(10, 30, 10, 30))

  51. ##p6  
  52. penguins %>%
  53.   ggplot() +
  54.   geom_histogram(aes(x=body_mass_g, fill=species),
  55.                alpha = 0.75, color="black") +
  56.   scale_x_continuous(limits = c(2000, 7000)) +
  57.   scale_fill_manual(values=pal, guide="none") +
  58.   theme(plot.margin = margin(10, 30, 10, 30))
复制代码

3.配色方案三

217625ab481cb0873cd875a52d5f6924.png


a024f03753f1f8454fba35a68994c886.png
作图数据跟代码:
  1. library(tidyverse)
  2. library(palmerpenguins)
  3. library(patchwork)


  4. pal = c("#3c0316", "#cd0254",  "#ff3184")
  5. ## p1
  6. penguins %>%
  7.   ggplot() +
  8.   geom_density(aes(x=body_mass_g, fill=species),
  9.                alpha = 0.75) +
  10.   scale_x_continuous(limits = c(2000, 7000)) +
  11.   scale_fill_manual(values=pal, guide="none") +
  12.   theme(plot.margin = margin(10, 30, 10, 30))

  13. ## p2
  14. penguins %>%
  15.   ggplot() +
  16.   geom_point(aes(x=bill_length_mm, y=bill_depth_mm, fill=species),
  17.                size=2.5, shape=21, color = "black") +
  18.   scale_fill_manual(values=pal, guide="none") +
  19.   theme(plot.margin = margin(10, 30, 10, 30))

  20. ##p3
  21. penguins %>%
  22.   ggplot() +
  23.   geom_boxplot(aes(x=sex, y=bill_length_mm, fill=species)) +
  24.   scale_fill_manual(values=pal, guide="none") +
  25.   theme(plot.margin = margin(10, 30, 10, 30))

  26. ##p4
  27. penguins %>%
  28.   filter(!is.na(sex)) %>%
  29.   ggplot(aes(x=sex, y=bill_length_mm)) +
  30.   geom_bar(aes(fill=species),
  31.            stat = "summary", fun="mean",
  32.            color="black", width = 0.75, position = position_dodge()) +
  33.   # geom_jitter(size=2) +
  34.   scale_fill_manual(values=pal, guide="none") +
  35.   theme(plot.margin = margin(10, 30, 10, 30))

  36. ##p5
  37. data = read_csv("./data/误差棒图.csv")
  38. data %>%
  39.   mutate(upper = `Estimation coefficients` + SEM,
  40.          lower = `Estimation coefficients` - SEM) -> df


  41. ggplot(data = df) +
  42.   geom_errorbar(aes(x=Month, ymin=lower, ymax=upper),
  43.                 width = 0.25) +
  44.   geom_line(aes(x=Month, y=`Estimation coefficients`, color=group),
  45.             linewidth=1.75) +
  46.   geom_point(aes(x=Month, y=`Estimation coefficients`, fill=group),
  47.              shape=21, size=4.5) +
  48.   scale_fill_manual(values=pal, guide="none") +
  49.   scale_color_manual(values=pal, guide="none") +
  50.   theme(plot.margin = margin(10, 30, 10, 30))

  51. ##p6  
  52. penguins %>%
  53.   ggplot() +
  54.   geom_histogram(aes(x=body_mass_g, fill=species),
  55.                alpha = 0.75, color="black") +
  56.   scale_x_continuous(limits = c(2000, 7000)) +
  57.   scale_fill_manual(values=pal, guide="none") +
  58.   theme(plot.margin = margin(10, 30, 10, 30))
复制代码


4.配色方案四

d8df6d1ccde3734428244d202742081d.png

ece954691f3e3bf5f2f8e8bff51fa3ff.png
作图数据跟代码:
  1. library(tidyverse)
  2. library(palmerpenguins)
  3. library(patchwork)


  4. pal = c("#015e8a", "#0290b4",  "#5fcad0")
  5. ## p1
  6. penguins %>%
  7.   ggplot() +
  8.   geom_density(aes(x=body_mass_g, fill=species),
  9.                alpha = 0.75) +
  10.   scale_x_continuous(limits = c(2000, 7000)) +
  11.   scale_fill_manual(values=pal, guide="none") +
  12.   theme(plot.margin = margin(10, 30, 10, 30))

  13. ## p2
  14. penguins %>%
  15.   ggplot() +
  16.   geom_point(aes(x=bill_length_mm, y=bill_depth_mm, fill=species),
  17.                size=2.5, shape=21, color = "black") +
  18.   scale_fill_manual(values=pal, guide="none") +
  19.   theme(plot.margin = margin(10, 30, 10, 30))

  20. ##p3
  21. penguins %>%
  22.   ggplot() +
  23.   geom_boxplot(aes(x=sex, y=bill_length_mm, fill=species)) +
  24.   scale_fill_manual(values=pal, guide="none") +
  25.   theme(plot.margin = margin(10, 30, 10, 30))

  26. ##p4
  27. penguins %>%
  28.   filter(!is.na(sex)) %>%
  29.   ggplot(aes(x=sex, y=bill_length_mm)) +
  30.   geom_bar(aes(fill=species),
  31.            stat = "summary", fun="mean",
  32.            color="black", width = 0.75, position = position_dodge()) +
  33.   # geom_jitter(size=2) +
  34.   scale_fill_manual(values=pal, guide="none") +
  35.   theme(plot.margin = margin(10, 30, 10, 30))

  36. ##p5
  37. data = read_csv("./data/误差棒图.csv")
  38. data %>%
  39.   mutate(upper = `Estimation coefficients` + SEM,
  40.          lower = `Estimation coefficients` - SEM) -> df


  41. ggplot(data = df) +
  42.   geom_errorbar(aes(x=Month, ymin=lower, ymax=upper),
  43.                 width = 0.25) +
  44.   geom_line(aes(x=Month, y=`Estimation coefficients`, color=group),
  45.             linewidth=1.75) +
  46.   geom_point(aes(x=Month, y=`Estimation coefficients`, fill=group),
  47.              shape=21, size=4.5) +
  48.   scale_fill_manual(values=pal, guide="none") +
  49.   scale_color_manual(values=pal, guide="none") +
  50.   theme(plot.margin = margin(10, 30, 10, 30))

  51. ##p6  
  52. penguins %>%
  53.   ggplot() +
  54.   geom_histogram(aes(x=body_mass_g, fill=species),
  55.                alpha = 0.75, color="black") +
  56.   scale_x_continuous(limits = c(2000, 7000)) +
  57.   scale_fill_manual(values=pal, guide="none") +
  58.   theme(plot.margin = margin(10, 30, 10, 30))
复制代码
来源:置身数内  数新社
回复 关闭延时

使用道具 举报

您需要登录后才可以回帖 登录 | 注册  

本版积分规则

快速回复 返回顶部 返回列表