美文网首页
Density plot 以及cumulative plot

Density plot 以及cumulative plot

作者: 余绕 | 来源:发表于2020-07-22 20:47 被阅读0次

Density plot

x <- rnorm(20000, 49.2, 1.7)
y <- rnorm(20000, 51.3, 0.82)
z <- rnorm(20000, 39.1, 0.35)

ggdata <- data.frame(x, y, z)


# Melt the data frame
ggdata1 <- melt(ggdata)


head(ggdata1) 
ggplot(data = ggdata1,aes(x=ggdata1$value))+geom_density(aes(fill=ggdata1$variable),alpha=0.3,size=0.5)+scale_fill_manual(
  
  values = c("x" = "Magenta2", 
             "y" = "LightGreen" ,
             "z"="yellow"
  ))+xlim(0,100)

image.png

Cumulative plot

library(ggplot2)
The function is #ecdf
Data
Let's start by generating some data to work with.


head(ggdata1)
tail(ggdata1)
ggplot(ggdata1, aes(x=value)) + stat_ecdf(aes(colour=variable),lwd=1)+xlim(0,100)+
  scale_colour_manual(
    
    values = c("x" = "Magenta2", 
               "y" = "LightGreen",
                "z"="yellow"))

ks.test(x=ggdata$x,y=ggdata$y) #计算x,y之间的p值

image.png

相关文章

网友评论

      本文标题:Density plot 以及cumulative plot

      本文链接:https://www.haomeiwen.com/subject/imntlktx.html