I'm trying to use geom_area()
in a different way, e.g. AUC. I refer to the example in https://www.sthda.com/english/wiki/ggplot2-area-plot-quick-start-guide-r-software-and-data-visualization
dat <- with(density(df$weight), data.frame(x, y))
ggplot(data = dat, mapping = aes(x = x, y = y)) +
geom_line()+
geom_area(mapping = aes(x = ifelse(x>65 & x< 70 , x, 0)), fill = "red") +
xlim(30, 80)
Can someone help me understand why the result is different when we remove xlim(30, 80)
?
The different in the two images are below:enter image description here