Description
Hi, Teun!
In the process of using ggplot for plotting fitted lines, I came across a scenario of trying to show confidence intervals using line segments rather than shaded space. I asked a question on stackoverflow, But I don't think it's a very elegant or user-friendly solution.
I used the following code approach to achieve the results I wanted to show:
library(ggplot2)
ggplot(data = mpg, aes(x = displ,y = hwy))+
geom_point()+
geom_smooth(method = "lm", se = FALSE, color = "black") +
stat_smooth(method = "lm",
geom = 'ribbon',
fill = NA,
linetype = 2,
se = TRUE, color = "blue")
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
Created on 2025-07-09 with reprex v2.1.1
I know that the code actually does the same calculation twice for the same process.
Is there any chance that similar to the previous additions to the whiskers, staples and median line related properties of geom_boxplot
, geom_smooth
could be adjusted appropriately as well? It's not even about aesthetics, it's about simply adjusting basic properties like colour/color, linewidth and linetype.
I hope I'm not disturbing you and interfering with the release of a new version of ggplot.
Best wishes,
Hu