Is there any difference between `geom_a(stat=“b”,

2019-06-20 03:48发布

问题:

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?

回答1:

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.



标签: r ggplot2