Skip to content

Instantly share code, notes, and snippets.

@will-r-chase
Created May 16, 2022 02:39
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 will-r-chase/552faf326e996f701d8ca0befafa6652 to your computer and use it in GitHub Desktop.
Save will-r-chase/552faf326e996f701d8ca0befafa6652 to your computer and use it in GitHub Desktop.
library(tidyverse)
#Your turn
#This is some data for a line chart
air <-
airquality %>%
filter(Month == 5) %>%
select(Temp, Ozone, Wind, Day) %>%
pivot_longer(cols = 1:3)
#take this chart, and change the color of the lines so that
#Ozone is blue, Temp is orange, and Wind is green
ggplot(air) +
geom_line(aes(x = Day, y = value, color = name)) +
theme_minimal()
#take this plot and adjust the colors so that
#the bubbles are on a sequential scale from white to green
ggplot(mtcars) +
geom_point(aes(x = wt, y = hp, color = mpg), size = 4, alpha = 0.8) +
theme_minimal()
#generate some dummy data
x <- LETTERS[1:20]
y <- paste0("var", seq(1,20))
data <- expand.grid(X=x, Y=y)
data$Z <- runif(400, -5, 5)
#adjust this heatmap so that the colors
#are a diverging scale going from red to white to blue
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment