Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add geom_abline to each facet_matrix facet? #228

Closed
pointOfive opened this issue Mar 3, 2021 · 1 comment
Closed

How do I add geom_abline to each facet_matrix facet? #228

pointOfive opened this issue Mar 3, 2021 · 1 comment

Comments

@pointOfive
Copy link

mpg %>% add_column(slope=1) %>% add_column(intercept=0) %>%
ggplot(aes(x = .panel_x, y = .panel_y, fill = drv, colour = drv)) + 
  geom_point(shape = 16, size = 0.5, position = 'auto') + 
  geom_autodensity(alpha = 0.3, colour = NA, position = 'identity') + 
  geom_abline(aes(intercept=intercept, slope=slope)) +
  geom_smooth(aes(colour = NULL, fill = NULL)) + 
  facet_matrix(vars(fl, displ, hwy), layer.diag = 2, layer.continuous = TRUE,
               layer.mixed = TRUE, layer.discrete = TRUE) -> out

only puts it on the first pairwise scatter facets.

Alternatively, adding a single line to the "flurry-of-facets" code here

ggplot(mpg, aes(x = .panel_x, y = .panel_y, fill = drv, colour = drv)) + 
  geom_point(shape = 16, size = 0.5, position = 'auto') + 
  geom_autodensity(alpha = 0.3, colour = NA, position = 'identity') + 
  geom_smooth(aes(colour = NULL, fill = NULL)) + 
  facet_matrix(vars(fl, displ, hwy), layer.diag = 2, layer.continuous = TRUE,
               layer.mixed = -3, layer.discrete = -3)

just errors like this:

Error: Can't subset columns that don't exist.
x Column `fl` doesn't exist.
@thomasp85 thomasp85 added bug an unexpected problem or unintended behavior and removed bug an unexpected problem or unintended behavior labels Jan 18, 2024
@thomasp85
Copy link
Owner

I'm afraid that I can't reproduce the last error you describe. As for why you only see the line in the first pairwise panels it's because the line is not visible in the others as they are in other areas of the coordinate system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants