geom Extra Lines| Adding a line in ggplot

geom Extra Lines| Adding a line in ggplot

geom_vline()
geom_hline()
geom_abline()

library(ggplot2)
library(patchwork)

P1 <- ggplot(mtcars)+ geom_point(aes(mpg, cyl)) +
geom_vline( xintercept = 20) + ggtitle('vline') +theme_light()
P2 <- ggplot(mtcars)+ geom_point(aes(mpg, cyl)) +
geom_hline( yintercept = 7) + ggtitle('hline') +theme_light()
P3 <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_abline(intercept = 25, slope = -1) +
ggtitle("abline")+theme_light()

P3|(P1/P2)

Nu06nx.png

More

geom Extra Lines| Adding a line in ggplot

https://karobben.github.io/2020/06/19/R/geom-Extra-Lines/

Author

Karobben

Posted on

2020-06-19

Updated on

2024-01-22

Licensed under

Comments