如何在r中ggplot多个变量的CDF?

问题描述

我有DF data.frame。我想使用plot cumulative distribution function (CDF)variables的{​​{1}} DF。使用以下代码会产生ggplot,但由于plot的数据范围较大,因此我对variables的理解不太好。我不想使用plot-希望将所有multiple facets variables放在plotted上。

single panel

解决方法

我们可以使用facet_wrap来标识

ggplot(DF,aes(x = value,col = variable))+
   stat_ecdf(lwd = 1.2) +
   facet_wrap(~ variable)
,

如果您不想使用构面,则可以使用对数刻度:

library(ggplot2)

set.seed(123)

DF <- reshape::melt(data.frame(p1 = runif(200,1,10),p2 = runif(200,-2,1),p3 = runif(200,0.05),p4 = runif(200,100,4000)))

ggplot(DF,col = variable),log='x')+
  stat_ecdf(lwd = 1.2)+
  scale_x_log10()

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...