Reputation: 3152
I have a dataset with a factor with two levels, a continuous variable and a continuous outcome. I would like to show the two smoothed curves but only one curve should have a confidence region. Here is the dataset:
# Data
xdf <- data.frame(x = rep(1:10,2)
, y = c(rpois(10,10),rpois(10,20))
, g = rep(c("A","B"), each=10)
)
and here is the plot
# Plot
windows(width=12, height=20)
ggplot(xdf, aes(x,y,linetype=g)) +
geom_smooth(se=TRUE) +
geom_point()
Any idea how to prevent one CI-region?
Thanks for help.
Upvotes: 1
Views: 24
Reputation: 25608
The simplest way I see is overriding data
argument like so:
ggplot(xdf, aes(x,y,linetype=g)) +
geom_smooth(se = F) +
geom_point() +
geom_smooth(data = xdf[xdf$g == "A", ], se = T)
Upvotes: 1