ProjectMOSAIC / ggformula

Provides a formula interface to 'ggplot2' graphics.
Other
39 stars 11 forks source link

gf_abline: options linetype & color have no effect #76

Closed lbcollins closed 6 years ago

lbcollins commented 6 years ago

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)

ggformula_test

rpruim commented 6 years ago

This is a duplicate of #70 and has already been fixed. It will be in the next CRAN release but is available via github until then.