`geom_a(stat =“b”,...)`和`stat_b(geom =“a”,...)“之间是否有区别? [英] Is there any difference between `geom_a(stat="b", ...)` and `stat_b(geom="a",...)`?
本文介绍了`geom_a(stat =“b”,...)`和`stat_b(geom =“a”,...)“之间是否有区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到了两种用法,但我不知道2在实际中的区别。
为什么
stat_vline(xintercept =mean,geom =vline)#this works
但是
geom_vline(xintercept =mean,stat =vline)#这不起作用
这是否意味着在传递平均值$ c之后$ c>到下一层,它是
vline
在这种情况下,函数变成字符?这种行为是否一般?
解决方案
您可能发现了一个错误。如果您指定了美学映射(再次)它可以工作:
p < - ggplot(mtcars,aes(x = wt, y = mpg))+ geom_point()
p + geom_vline(aes(x = wt,y = mpg),xintercept =mean,stat =vline)
对于 ggplot2
的典型文件有点稀疏,这使得很难判断这是否是故意的。
I have seen both usages, yet I don't know the difference between 2 in practical.
And, why
stat_vline(xintercept="mean", geom="vline") # this works
But
geom_vline(xintercept="mean", stat="vline") # this doesn't work
Does that mean after passing mean
to a next layer which is vline
in this case, the function becomes character? Is this behaviour general?
解决方案
You might have found a bug. If you specify the aesthetics mapping (again) it works:
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + geom_vline(aes(x=wt, y=mpg), xintercept="mean", stat="vline")
Typical for ggplot2
documentation is somewhat sparse, which makes it difficult to judge if this is intentional.
这篇关于`geom_a(stat =“b”,...)`和`stat_b(geom =“a”,...)“之间是否有区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文