pythonic生物人

Nature认定的统计、可视化神器!

看到Nature cancer上一篇文章中的图大量使用统计指标(如红色方框标记,包含APA 格式统计结果、数据组间P value统计指标、均值等描述性统计指标等),

来源,s43018-023-00628-6
来源,s43018-023-00628-6

这类图如果使用ggplot2也可以,但是,如果使用ggstatsplot实现则特别简单。

下面介绍如何实现文中的图。

Extended Data Fig. 7 a原图,
Extended Data Fig. 7 a原图,

ggstatsplot实现,

set.seed(123)
library(ggplot2)

ggbarstats(
  data             = movies_long,
  x                = mpaa,
  y                = genre,
  title            = "MPAA Ratings by Genre",
  xlab             = "movie genre",
  legend.title     = "MPAA rating",
  ggplot.component = list(ggplot2::scale_x_discrete(guide = ggplot2::guide_axis(n.dodge = 2))),
  palette          = "Set2"
)
Image
Extended Data Fig. 5 b原图,
Extended Data Fig. 5 b原图,

ggstatsplot实现,

set.seed(123)
library(WRS2) ## for data
library(afex) ## to run ANOVA

ggwithinstats(
  data    = WineTasting,
  x       = Wine,
  y       = Taste,
  title   = "Wine tasting"
)
Image
Fig. 6 c原图,
Fig. 6 c原图,

ggstatsplot实现,

set.seed(123)

ggpiestats(
  data         = mtcars,
  x            = am,
  y            = cyl,
  package      = "wesanderson",
  palette      = "Royal1",
  title        = "Dataset: Motor Trend Car Road Tests",
  legend.title = "Transmission"
)
Image

当然,ggstatsplot还有其它方法,

correlation plot,
correlation plot,
single variable分布plot,
single variable分布plot,
marginal plot,
marginal plot,

等等......


-more-

👉matplotlib教程:20w字+数百张图形+1W行代码+详细代码注释+学习交流群

图片

👉seaborn教程:12.3万字+500多张图形+8000行代码

图片

👉R可视化教程:39个章节+20w字+数百张图

图片
图片

加入学习

👇(收费,请备注:299)

图片