Feature Request:Add some parameters to `geom_smooth` to adjust the properties of the lines at the edges of the confidence intervals.
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 7k
- Forks
- 2.1k
- Avg merge
- 59m
- Merged PRs (30d)
- 2
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the geom_smooth() and stat_smooth() entry points shown in the issue, and reproduce the supplied mpg example to understand the desired confidence-interval edge lines. Determine how color, linewidth, and linetype should apply to those edges without requiring the duplicated smoothing calls; done means the requested properties can be adjusted through the smooth-layer interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100