render this (mybooks)

filteredbooks <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readdate) |>
  summarise(bookspermonth = n(),
    sumpages = sum(pages),
            meanpages = mean(pages),
            meanapproval = mean(goodreads),
            meanpopularity = mean(numgoodreads),
            authorcount = n_distinct(author))

ggplot(filteredbooks, aes(x = readdate, y = bookspermonth, color = sumpages)) +
  geom_line() +
  scale_x_date(date_breaks = "2 month", date_labels = "%m/%y") +
  scale_color_gradient(high = "#FCD4CA", low = "#8EB0F5", aesthetics = "color")

readbooksnumber <- cleanbooks |>
  group_by(readdate) |>
  summarise(bookspermonth = n())


obscurebooks <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readmy, readdate) |>
  summarise(meanpopularity = mean(numgoodreads))

obscurebooksX <- obscurebooks |> left_join(readbooksnumber, by = "readdate")

ggplot(obscurebooksX, aes(x = readdate, y = meanpopularity, color = bookspermonth)) +
  geom_line(size = 0.75) +
  scale_color_gradient(low = "#A4C6B8", high = "#651461", aesthetics = "color") +
  scale_x_date(breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  labs(title = "Popularity of books I've read",
       x = "Date", 
       y = "Mean number of Goodreads reviews",
       color = "Books read") +
  theme(axis.line = element_line(linewidth = 0.6, colour = "#7F0078", arrow = arrow(angle = 30, length = unit(0.1, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#DFDEEE", colour = "#400C3E", linewidth = 1.6),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#C1D2DE", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"),
    legend.position = c(.13, .73),
   # legend.key.size = unit(.5, 'cm')
  )

cleanauthors <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readmy, readdate) |>
  summarise(authorcount = n_distinct(author))


cleanauthorsX <- cleanauthors |> left_join(readbooksnumber, by = "readdate")

ggplot(cleanauthorsX, aes(x = readdate, y = authorcount, color = bookspermonth)) +
  geom_line(size = 0.5) +
  labs(title = "Number of different authors I've read per month",
       x = "Month",
       y = "Number of authors",
       color = "Books read",
       caption = "Source: meeeee") +
  scale_color_gradient(high = "#432371", low = "#FAAE7B", aesthetics = "color") +
  scale_x_date(date_breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  theme(
    axis.line = element_line(linewidth = 0.6, colour = "#432371", arrow = arrow(angle = 30, length = unit(0.1, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#F0C9EB", colour = "#45003C", linewidth = 1.6),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#E7B6E1", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"), 
    legend.position = c(.13, .73)
  )

meanenjoyment <- cleanbooks |>
  group_by(readmonth) |>
  filter(readyear != "2021") |>
  select(-title, -fin, -readagain, -recommendvalue, -strength, -character, -funny, -serious, -lgbt, -romance, -series, -amazon, -numamazon, -notes, -coverinfatuation) |>
  mutate(meanenjoy = mean(enjoyment),
         meanrate = mean(personalrate))


meanenjoymentX <- meanenjoyment |>
  left_join(readbooksnumber, by = "readdate")



ggplot(meanenjoymentX, aes(x = readdate, y = meanenjoy, color = bookspermonth)) +
  geom_line(size = 0.5) +
  labs(title = "How much I enjoy my books, on average, per month",
       x = "Month",
       y = "Average enjoyment rating",
       color = "Books read") +
  scale_color_gradient(high = "#440021", low = "#FFBFAE", aesthetics = "color") +
  scale_x_date(date_breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  theme(
    axis.line = element_line(linewidth = 0.6, colour = "#440021", arrow = arrow(angle = 30, length = unit(0.2, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#fce2db", colour = "black", linewidth = 3),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#fce2db", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"),
    legend.position = c(.13, .3)
  )

goodreadbooks <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readmy, readdate) |>
  summarise(meanapproval = mean(goodreads))

goodreadbooksX <- goodreadbooks |> left_join(readbooksnumber, by = "readdate")

ggplot(goodreadbooksX, aes(x = readdate, y = meanapproval, color = bookspermonth)) +
  geom_line() +
  scale_color_gradient(low = "#FCA0F1", high = "#780016", aesthetics = "color") +
  scale_x_date(breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  labs(title = "Goodreads approval of my monthly books",
       x = "Date", 
       y = "Average Goodreads review ratings",
       color = "Books read") +
  theme(axis.line = element_line(linewidth = 0.6, colour = "#790016", arrow = arrow(angle = 30, length = unit(0.1, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#FFDCF3", colour = "#6C0014", linewidth = 1.6),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#FFD4F0", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"),
    legend.position = c(.8, .3)
  )

lengthbooks <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readdate) |>
  summarise(meanpages = mean(pages))

lengthbooksX <- lengthbooks |> left_join(readbooksnumber, by = "readdate")


ggplot(lengthbooksX, aes(x = readdate, y = meanpages, color = bookspermonth)) +
  geom_line(size = 0.5) +
  scale_color_gradient(low = "#43C197", high = "#1C1554", aesthetics = "color") +
  scale_x_date(breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  labs(title = "Average length of books I've read",
       x = "Date", 
       y = "Average length per month",
       color = "Books read") +
  theme(axis.line = element_line(linewidth = 0.6, colour = "#0C0F44", arrow = arrow(angle = 30, length = unit(0.1, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#F0FFFC", colour = "#003347", linewidth = 1.6),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#E1F9EC", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"),
    legend.key.size = unit(0.5, "cm"),
    legend.position = c(.24, .77)
  )

pagesbooks <- cleanbooks |>
  filter(readyear != "2021") |>
  group_by(readdate) |>
  summarise(sumpages = sum(pages))

pagesbooksX <- pagesbooks |> left_join(readbooksnumber, by = "readdate")


ggplot(pagesbooksX, aes(x = readdate, y = sumpages, color = bookspermonth)) +
  geom_line(size = 0.75) +
  geom_point() +
  scale_color_gradient(low = "#E87D86", high = "#080808", aesthetics = "color") +
  scale_x_date(breaks = "2 month", date_labels = "%m/%y") +
  theme_light() +
  labs(title = "Number of pages read per month",
       x = "Date", 
       y = "Total pages",
       color = "Books read") +
  theme(axis.line = element_line(linewidth = 0.6, colour = "#2D1517", arrow = arrow(angle = 30, length = unit(0.1, "inches"), ends = "last", type = "open")),
    plot.background = element_rect(fill = "#FFEDED", colour = "#2D1517", linewidth = 1.6),
    plot.margin = margin(0.8, 0.8, 0.8, 0.8, "cm"),
    legend.background = element_rect(fill = "#F8D5D5", linewidth = 0.3),
    legend.ticks = element_line(color = "transparent", size = unit(1, "inches")),
    legend.ticks.length = unit(3, "inches"),
 #   legend.key.size = unit(0.5, "cm"),
    legend.position = c(.14, .75)
  )