How does one change the color of the line border in geom_smooth() ?
geom_smooth()
library(ggplot2) mtcars$cyl <- as.factor(mtcars$cyl) ggplot(mtcars, aes(x=wt, y=mpg, color=cyl, shape=cyl)) + geom_point() + geom_smooth(method=lm)
It should look something like this:
Thank you for your time!
One way is to plot wider, black lines first. Note that you need to add group = cyl for this to work properly.
group = cyl
ggplot(mtcars, aes(x=wt, y=mpg, group = cyl, color = cyl)) + geom_point() + geom_smooth(method = lm, size = 2.5, color = "black", se = FALSE) + geom_smooth(method = lm)
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.