Is there a way, in geom_smooth()
(from libray ggplot2 ), to have the confidence interval (parameters se = T
) for a line but not for the other ?
mpg %>%
filter(class %in% c('compact', 'midsize')) %>%
ggplot(aes(x = displ, y = as.numeric(hwy), color = class)) +
geom_smooth(se = T)
In the graph below, I would like to keep the confidence interval for the blue line, but to remove the one of the red line. As se
parameter is not in the aes()
function, I don't manage to pass different values in it. Moreover, there is no function like scale_fill_manual()
, to specify different values.
This should work:
mpg %>%
filter(class %in% c('compact', 'midsize')) %>%
ggplot(aes(x = displ, y = as.numeric(hwy), color = class)) +
geom_smooth(data = . %>% filter(class == "compact"), method = "loess", se = F) +
geom_smooth(data = . %>% filter(class == "midsize"), method = "loess", se = T)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.