I find that neither gf_abline, gf_hline, nor gf_vline are affected by (at least) the linetype and color options.
Here is a working example comparing adding lines to a gf_point plot using ggformula (gf_abline, gf_hline, gf_vline) vs. ggplot2 (geom_abline, geom_hline, geom_vline):
library(ggformula)
library(gridExtra)
set.seed(12345)
x <- rnorm(100, m=10, s=2)
y = 2 + 3*x + rnorm(100, s = 3)
p1 <- gf_point(y ~ x) %>%
gf_labs(x = "x-axis (gf_ lines added)", y = "y-axis") %>%
gf_hline(yintercept = mean(y), linetype = "dashed", color = "blue") %>%
gf_vline(xintercept = mean(x), linetype = "dotted", color = "red") %>%
gf_abline(intercept = 2, slope = 3, color = "green")
p2 <- gf_point(y ~ x) %>%
gf_labs(x = "x-axis (geom_ lines added)", y = "y-axis") +
geom_hline(yintercept = mean(y), linetype = "dashed", color = "blue") +
geom_vline(xintercept = mean(x), linetype = "dotted", color = "red") +
geom_abline(intercept = 2, slope =3, color = "green")
grid.arrange(p1, p2, ncol=2)
I find that neither
gf_abline
,gf_hline
, norgf_vline
are affected by (at least) thelinetype
andcolor
options.Here is a working example comparing adding lines to a
gf_point
plot usingggformula
(gf_abline
,gf_hline
,gf_vline
) vs.ggplot2
(geom_abline
,geom_hline
,geom_vline
):