Skip to content

Feature Request:Add some parameters to geom_smooth to adjust the properties of the lines at the edges of the confidence intervals. #6551

Open
@Breeze-Hu

Description

@Breeze-Hu

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.

https://stackoverflow.com/questions/79668693/plotting-the-95-error-margin-segments-of-the-fitted-line-and-controlling-the-li

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions