Skip to content

Instantly share code, notes, and snippets.

@stevenworthington
Created April 20, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenworthington/d355ed00c5aa0243bcef to your computer and use it in GitHub Desktop.
Save stevenworthington/d355ed00c5aa0243bcef to your computer and use it in GitHub Desktop.
ggplot regression example using facets
data(mtcars)
library(ggplot2)
plot1 <- ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~ cyl) +
theme_bw()
ggsave(plot1, file = "facet_reg.pdf", height = 7, width = 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment