Skip to content

Instantly share code, notes, and snippets.

@amoeba
Last active October 6, 2019 08:57
Show Gist options
  • Save amoeba/7576126 to your computer and use it in GitHub Desktop.
Save amoeba/7576126 to your computer and use it in GitHub Desktop.
Anscombe's Quartet with ggplot2
library(ggplot2)
theme_set(theme_bw(base_size=18))
anscombe_m <- data.frame()
for(i in 1:4)
anscombe_m <- rbind(anscombe_m, data.frame(set=i, x=anscombe[,i], y=anscombe[,i+4]))
ggplot(anscombe_m, aes(x, y)) + geom_point(size=5, color="red", fill="orange", shape=21) + geom_smooth(method="lm", fill=NA, fullrange=TRUE) + facet_wrap(~set, ncol=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment