Skip to content

Instantly share code, notes, and snippets.

@ibombonato
Created December 2, 2016 17:21
Show Gist options
  • Save ibombonato/fa1539d3a5f434bdff4a3fc13a96e799 to your computer and use it in GitHub Desktop.
Save ibombonato/fa1539d3a5f434bdff4a3fc13a96e799 to your computer and use it in GitHub Desktop.
Plotting all variables from a data frame
library(ggplot2)
library(tidyverse)
df <- mtcars %>%
gather(-mpg, key="var", value = "value")
ggplot(df, aes(x = value, y = mpg)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm") +
facet_wrap(~var, scales = "free") +
scale_color_gradient(low = "orange", high = "blue") +
theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment