Closed
Description
geom_area()
doesn't play well with duplicated x
values. The docs state:
geom_area
is a special case ofgeom_ribbon
, where theymin
is fixed to 0.
But when there are multiple values of y
for a given value of x
, the two are not equivalent. The geom_ribbon()
result matches the intuition of "geom_line()
but with the area under the curve filled in":
library(tidyverse)
df <- data.frame(x = c(1, 2, 2, 3), y = 1:4)
ggplot(df, aes(x, y)) + geom_ribbon(aes(ymin = 0, ymax = y))
However, it seems this scenario results in geom_area()
having the equivalent of ymin = min(y)
and ymax = sum(y)
in geom_ribbon()
.
ggplot(df, aes(x, y)) + geom_area()
I'm happy to dig a bit further and see if I can submit a PR for this.
Created on 2018-09-06 by the reprex package (v0.2.0.9000).