Round lineend geom_smooth

Viewed 191

How to make round lineends for geom_smooth? For there is no lineend argument, geom_smooth(lineend = "round") obviously fails. I also tried in vain:

update_geom_defaults("smooth", list(lineend = "round"))

So either there is some simple option I am not aware of or lineend is hard coded and thus one needs to come up with a custom geom_smooth function which I don't know how to.

Don't think it needs a MRE, but:

library(ggplot2)
dat = data.frame(x = 1:3, y = 2:4)
ggplot(dat, aes(x, y)) + geom_smooth(size = 4)  # increase size to discern lineends
1 Answers

This could be achieved using stat_smooth:

library(ggplot2)

dat = data.frame(x = 1:3, y = 2:4)

ggplot(dat, aes(x, y)) + stat_smooth(size = 4, geom = "line", lineend = "round", color = "blue")

Related