Confidence interval disappears in ggplot2 using coord_cartesian

Viewed 494

Limiting the x range by coord_cartesian makes the confidence interval created by stat_smooth disappear.

I noticed it happens with R 4.1.0 but not with R 4.0.2. The ggplot2 version I used was 3.3.5.

The first plot shows the confidence interval as a shade. The second plot should show the same confidence interval in the specified range. But with R 4.1.0, the shade disappear. Any one experiencing it?

library(ggplot2)
mtcars %>%
  ggplot(aes(x = wt, y = mpg)) +
  geom_point() +
  stat_smooth()

mtcars %>%
  ggplot(aes(x = wt, y = mpg)) +
  geom_point() +
  stat_smooth() +
  coord_cartesian(xlim = c(3, 4))
1 Answers
Related