Density plot 以及cumulative plot

2020-07-22  本文已影响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
上一篇 下一篇

猜你喜欢

热点阅读