【R包】tidyplots----取代ggplot2的科研绘图利器

发布于:2025-02-25 ⋅ 阅读:(24) ⋅ 点赞:(0)


在这里插入图片描述

介绍

tidyplots----取代ggplot2的科研绘图利器。tidyplots的目标是简化为科学论文准备出版的情节的创建。它允许使用一致和直观的语法逐渐添加,删除和调整情节组件。

在这里插入图片描述

安装

You can install the released version of tidyplots from CRAN with:

install.packages("tidyplots")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("jbengler/tidyplots")

Usage

Here are some examples. Also have a look at the getting started guide and the full documentation.

library(tidyplots)

study |> 
  tidyplot(x = treatment, y = score, color = treatment) |> 
  add_mean_bar(alpha = 0.4) |> 
  add_sem_errorbar() |> 
  add_data_points_beeswarm()

在这里插入图片描述

energy |> 
  tidyplot(x = year, y = energy, color = energy_source) |> 
  add_barstack_absolute()

在这里插入图片描述

energy |> 
  dplyr::filter(year %in% c(2005, 2010, 2015, 2020)) |> 
  tidyplot(y = energy, color = energy_source) |> 
  add_donut() |> 
  split_plot(by = year)

在这里插入图片描述

energy_week |> 
  tidyplot(x = date, y = power, color = energy_source) |> 
  add_areastack_absolute()

在这里插入图片描述

energy_week |> 
  tidyplot(x = date, y = power, color = energy_source) |> 
  add_areastack_relative()

在这里插入图片描述

study |> 
  tidyplot(x = group, y = score, color = dose) |> 
  add_mean_bar(alpha = 0.4) |> 
  add_mean_dash() |> 
  add_mean_value()

在这里插入图片描述

time_course |>
  tidyplot(x = day, y = score, color = treatment) |>
  add_mean_line() |>
  add_mean_dot() |>
  add_sem_ribbon()

在这里插入图片描述

climate |>
  tidyplot(x = month, y = year, color = max_temperature) |>
  add_heatmap()

在这里插入图片描述

study |> 
  tidyplot(x = treatment, y = score, color = treatment) |> 
  add_boxplot() |> 
  add_test_pvalue(ref.group = 1)

在这里插入图片描述

gene_expression |> 
  dplyr::filter(external_gene_name %in% c("Apol6", "Col5a3", "Vgf", "Bsn")) |> 
  tidyplot(x = condition, y = expression, color = sample_type) |> 
  add_mean_dash() |> 
  add_sem_errorbar() |> 
  add_data_points_beeswarm() |> 
  add_test_asterisks(hide_info = TRUE) |> 
  remove_x_axis_title() |> 
  split_plot(by = external_gene_name)

在这里插入图片描述

study |> 
  tidyplot(x = treatment, y = score, color = treatment) |> 
  add_mean_bar(alpha = 0.4) |> 
  add_sem_errorbar() |> 
  add_data_points_beeswarm() |> 
  view_plot(title = "Default color scheme: 'friendly'") |> 
  adjust_colors(colors_discrete_apple) |> 
  view_plot(title = "Alternative color scheme: 'apple'")

在这里插入图片描述

在这里插入图片描述

文档

参考

  • https://github.com/jbengler/tidyplots/
  • https://jbengler.github.io/tidyplots/
  • https://blog.csdn.net/qq_21478261/article/details/143786774