Skip to content

Instantly share code, notes, and snippets.

@chelseaparlett
Created March 28, 2020 18:57
Show Gist options
  • Save chelseaparlett/2de885b49a98f49adadb8c35e8609a5d to your computer and use it in GitHub Desktop.
Save chelseaparlett/2de885b49a98f49adadb8c35e8609a5d to your computer and use it in GitHub Desktop.
ggplot graphs as birds
library(tidyverse)
# 1
d <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/Beyonce_data.csv"))
ggplot(d,aes(x = factor(mode), y = danceability)) + geom_boxplot(aes(fill = factor(mode))) +
scale_fill_manual(values = c("#f83703", "#000000")) +
labs(title = "Dancibility of Beyonce Songs by Major and Minor Key", x = "mode") +
theme(legend.position = "none", panel.background = element_rect(fill = "#78a741", colour = "#83ba7d"),
panel.grid.major = element_line(colour = "burlywood3"),
panel.grid.minor = element_line(colour= "burlywood3"))
# 2
data(iris)
ggplot(iris, aes(x = Species, y = Sepal.Width, fill = Species)) +
geom_bar(stat = "identity") + scale_fill_manual(values = c("#e90205",
"#f6d304",
"#0657b1"))+
theme_minimal() +labs(title = "Iris Sepal Width by Species")
# 3
ggplot(d, aes(x = factor(key), y = valence, fill = factor(key))) +
geom_boxplot() +
theme(panel.background = element_rect(fill = "#fed2e1"),legend.position = "none") +
scale_fill_manual(values = c("#ca88eb",
"#fc64b7",
"#85c0cf",
"#baea94",
"#bfd862",
"#e5c44d",
"#f0b080",
"#f68f85",
"#f5b7d0",
"#da92ef",
"#e8d1ed",
"#ffffff"
)) +
labs(title = "Valence of Beyonce Songs by Key", x = "key")
# 4
d2 <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/winequality-red.csv"))
ggplot(d2, aes(x = residual.sugar, y = fixed.acidity, color = 1:nrow(d2))) +
geom_point() +
scale_color_gradient(
low = "#fd8e27",
high = "#2032ab",
na.value = "grey50",
guide = "colourbar",
aesthetics = "color"
) + geom_smooth(method = "lm", color = "#6f8a2b") +
theme_minimal() + theme(legend.position = "none", panel.background = element_rect(fill = "#bed765")) +
labs(title = "Wine Acidity and Sugar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment