关闭。这个问题需要details or clarity .它目前不接受答案。
想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.
4年前关闭。
Improve this question
有人能解释一下geom_density
位置选项stack
与 identity
.情节看起来非常不同,但仍然重叠。两者有什么根本区别?
最佳答案
出于某种原因,它没有在 geom_density
中解释。帮助。然而position="stack"
像这样堆叠值:
而position="identity"
像这样覆盖它们:
这是生成这些的代码:
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`")
关于r - ggplot中的位置堆栈与身份之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44033592/