r - `geom_a(stat="b", ... )` and ` stat_b(geom ="a",...)`之间有什么区别吗?

标签 r ggplot2

我见过这两种用法,但我不知道实际中 2 之间的区别。

而且,为什么

stat_vline(xintercept="mean", geom="vline") # this works


geom_vline(xintercept="mean", stat="vline") # this doesn't work

这是否意味着通过后mean到下一层 vline在这种情况下,函数变成了字符?这种行为是普遍的吗?

最佳答案

您可能发现了一个错误。如果您指定美学映射(再次),它会起作用:

p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + geom_vline(aes(x=wt, y=mpg), xintercept="mean", stat="vline")

典型用于 ggplot2文档有点稀少,这使得很难判断这是否是故意的。

关于r - `geom_a(stat="b", ... )` and ` stat_b(geom ="a",...)`之间有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18786161/

相关文章:

r - 如何在ggplot中改变binwidth?

r - 如何为 R 中的函数赋值

python - 将 Python 转换为 R

r - 如何将颜色和大小的比例组合成一个图例?

r - 绘制 2x2x2 时间序列的原始值和预测值

r - 使用ggplot2和R创建帕累托图

r - 填写图例、ggplot 的符号

r - 在 R 中计算 TWI?

r - 无法在R版本3.1.1中安装tidyr

r - 在变量中搜索字符串并返回匹配的字符串