본문 바로가기
R

(R) Kernal density curve /geom_density()/geom_line(stat="density")

by jangpiano 2020. 9. 3.
반응형

<geom_density()>


> ggplot(data=trees,aes(x=Volume))+geom_density()


<geom_line(stat="density") = geom_density()>


> ggplot(data=trees,aes(x=Volume))+geom_density()

 > ggplot(data=trees,aes(x=Volume))+geom_line(stat="density")

 

 


As you can see below, setting geom_density(adjust=1) means nothing. 

There is no difference between ggplot(data=trees,aes(x=Volume))+geom_desity() and ggplot(data=trees,aes(x=Volume))+geom_density(adjust=1) because basic set for adjust in geom_density() is 1. 


> ggplot(data=trees,aes(x=Volume))+geom_density()

 > ggplot(data=trees,aes(x=Volume))+geom_density(adjust=1)

 

 


<geom_density(fill=)>

If you want to fill the density function, you can set fill="color".

However, you cannot fill the graph geom_line() because it is a line graph. 

> ggplot(data=trees,aes(x=Volume))+geom_density()

 > ggplot(data=trees,aes(x=Volume))+geom_density(fill="white")

 

 


<geom_density(adjust=0.25)>

> ggplot(data=trees,aes(x=Volume))+geom_density(adjust=0.25,colour="red")

 > ggplot(data=trees,aes(x=Volume))+geom_density(adjust=0.25,fill="red")

 

 


<geom_density(adjust=2)>

> ggplot(data=trees,aes(x=Volume))+geom_density(adjust=2,colour="blue")

 > ggplot(data=trees,aes(x=Volume))+geom_density(adjust=2,fill="blue")

 

 


<expand_limits(x=,y=)>

> ggplot(data=trees,aes(x=Volume))+geom_density(adjust=2,colour="blue")+expand_limits(x=-20)

 > ggplot(data=trees,aes(x=Volume))+geom_line(stat="density",adjust=2,colour="blue")+expand_limits(x=0)

 

 


> ggplot(data=trees,aes(x=Volume))+geom_density(adjust=0.25,colour="red")+geom_density()+geom_density(adjust=2,colour="blue")




반응형