The original plot comes from a Tiny Tuesday challenge in 2018. Credit for the original goes to Thom Flaherty. He chose a ridgeline plot to compare how the number of new male and female comic book characters changes every year from 1935 to 2013. The plot conveys a lot of information, but is rather dense, and the overall trends can be difficult to perceive due to the overlap between the ridges and the amount of variance for each year. In addition, the plot uses the default R color palette, which can make it difficult for people with colorblindness to distinguish between categories, especially in a plot with as much overlap between categories as this one.
comics_yg <- comics %>% filter(sex %in% c("Female Characters", "Male Characters"), !is.na(year))
comics_yg <- comics_yg %>% group_by(year, sex) %>%
mutate(year_total = n()) %>% arrange(desc(year)) %>% mutate(str_year = as.character(year))
ggplot(comics_yg, aes(x = year_total, y = str_year, fill = sex)) + geom_density_ridges() +
scale_y_discrete(breaks = c("1940", "1960", "1980", "2000")) +
scale_x_continuous(breaks = c(0,100,200,300,400,500,600)) +
theme_ridges() +
theme_minimal() +
theme(panel.grid.major = element_line(colour = "black"))
## Picking joint bandwidth of 43.7
I chose to alter the aesthetics by putting year on the x-axis and new characters on the y-axis. This matches more closely with how a reader’s eye will travel across the graph. Interpreting the vertical timeline in the original plot requires more mental effort to interpret which direction the trends go in. I also changed the geometric object to a line plot instead of a ridgeline plot. This reduces the amount of unneccesary information that confuses the overall trend. It also allows for easier comparison between the number of new male and female characters each year. I looked up colorblind-friendly color palettes to choose colors that would be easy to distinguish for those with colorblindness.
ggplot(comics_yg, aes(x = year, y = year_total, group = sex, color = sex)) +
geom_line() +
theme_light() +
labs(x="Year", y = "Number of new characters", title = "New characters per year from 1935 to 2013", color = "Sex") +
scale_color_manual(values = c("Female Characters" = "#FFC107","Male Characters" = "#004D40"), labels = c("Female", "Male")) +
theme(legend.position = c(.25, .75),legend.title = element_text(), legend.background = element_rect(fill = "white", color = "gray"))
## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2
## 3.5.0.
## ℹ Please use the `legend.position.inside` argument of `theme()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.