2017-05-17 8 views

답변

3

어떤 이유인지 그것은 geom_density 도움말에 설명되어 있지 않습니다. 이 같은

enter image description here

position="identity" 반면 오버레이를 :

여기 enter image description here

그 생성 된 코드이다 : 그러나 position="stack"는 다음과 같이 값을 스택

n <- 1000 
A <- data.frame(id='A',x=rnorm(n, 5, 2)) 
B <- data.frame(id='B',x=rexp(n, 1/4)) 
C <- data.frame(id='C',x=rexp(n, 1/8)) 
D <- data.frame(id='D',x=rexp(n, 1/16)) 
df <- rbind(A,B,C,D) 

colorset = c('B'='red','A'='green','D'='black','C'='blue' ) 

ggplot(df, aes(x)) + 
    geom_density(aes(fill = id), alpha = .4, adjust = 2,position="stack") + 
    scale_fill_manual(values=colorset) + 
    scale_x_continuous(limits =c(0,40)) + labs(title="geom_density: position=`Stack`") 

ggplot(df, aes(x)) + 
    geom_density(aes(fill = id), alpha = .4, adjust = 2,position="identity") + 
    scale_fill_manual(values=colorset) + 
    scale_x_continuous(limits =c(0,40)) + labs(title="geom_density: position=`identity`")