Code
library(tidyverse)
library(ggplot2)
library(ggridges)
cleanbooks <- read_csv("CLEANBOOKS.csv")Load libraries and dataset
library(tidyverse)
library(ggplot2)
library(ggridges)
cleanbooks <- read_csv("CLEANBOOKS.csv")cleanbooks %>%
filter(numgoodreads > 200000) %>%
ggplot(aes(y = title)) +
geom_segment(aes(x = goodreads,
y = reorder(title, numgoodreads),
xend = amazon,
yend = title), color = "#A79E9E") +
geom_point(aes(x = goodreads, color = "Goodreads"), alpha = 0.6, size = 3) +
geom_point(aes(x = amazon,
color = "Amazon"), alpha = 0.6, size = 3) +
geom_point(aes(x = personalrate, color = "Personal rating"), alpha = 0.6, size = 3) +
scale_color_manual(values = c(
"Goodreads" = "#33a302",
"Amazon" = "#f3a3a3",
"Personal rating" = "#87BFFF"
)) +
labs(
title = "Book ratings, Amazon vs Goodreads (and myself)",
x = "Rating (0-5)",
y = "Book",
caption = "only using books I have read and that are highly popular on Goodreads"
) +
theme(
panel.grid = element_line(color = "#ECE8E8"),
panel.background = element_rect(color = "#f3a3a3", linewidth = 0.55, fill = "#fff"),
axis.line = element_line(color = "#33a302"),
axis.text.y = element_text(hjust = -0.0),
axis.title.y = element_blank(),
panel.grid.minor.y = element_line(color = "#D7DADA"),
panel.grid.major.y = element_line(color = "#D7DADA"),
panel.grid.minor.x = element_line(color = "#F9FAFA"), # make much paler than y
panel.grid.major.x = element_line(color = "#F9FAFA"), # make much paler than y
# why do those go on top of the y lines no matter what I do!!!!
legend.position = "bottom",
legend.background = element_blank(),
legend.title = element_blank()
)geom_point and geom_segment together to create lollipop plotgeom_point three times with the color for each specified as the names in the key (“Goodreads”, “Amazon”, “Personal rating”), then used scale_color_manual and scale_fill_manual to name the colorstheme(): used panel.background with element_rect to make the overall plot outline pinkaxis.line with element_line to make the x and y axis lines greenaxis.line after panel.background to have the green line appear on top of the pink lineaxis.text.y with element_text() only specifying hjust to make the y-axis labels be left alignedcleanbooks %>%
filter(genre != "Romance") %>% # this will serve for now
# plotting romance gives an empty bar lol
ggplot() +
geom_density_ridges(aes(x = enjoyment,
y = genre,
color = genre, fill = genre), alpha = 0.5) +
labs(
title = "Enjoyment distribution per book genre",
x = "Enjoyment rating",
# DO NOT FUCK with the color key
caption = "1-10 rating by me of how much I enjoyed books I've read in the past 2 years"
) +
scale_color_manual(values = c(
"Unrealistic Fiction" = "#BC1B68",
"Science Fiction" = "#C44579",
"Realistic Fiction" = "#CB6E8A",
"Fantasy" = "#D3989B"
), aesthetics = "color") +
scale_fill_manual(values = c(
"Unrealistic Fiction" = "#440021",
"Science Fiction" = "#824050",
"Realistic Fiction" = "#C17F7F",
"Fantasy" = "#FFBFAE"
), aesthetics = "fill")+
scale_alpha(guide = "none") +
theme(
axis.line = element_line(linewidth = .25, color = "#440021"),
panel.background = element_rect(fill = "#FFF1ED"),
panel.grid.y = element_line(color = "#F5D2D2"),
panel.grid.x = element_line(color = "#8FC6C9"),
axis.title.y = element_blank(),
plot.background = element_rect(fill = "#FEF5F2"
))ggridges used for genre ridgeline plot