Skip to content

Commit

Permalink
I created a monster!
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgios Karamanis committed May 19, 2019
1 parent c89f6a2 commit e72d04a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
Binary file added week-20/nobelShared-Chemistry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week-20/nobelShared-Economics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week-20/nobelShared-Literature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week-20/nobelShared-Medicine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added week-20/nobelShared-Peace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 31 additions & 13 deletions week-20/nobelShared.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,49 @@ library(tidyverse)

nobel_winners <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-05-14/nobel_winners.csv")

decadesLabels <- function(string) {
return(as.numeric(string)+1900)
}

filterCategory = "Medicine"

nobel_winners %>%
filter(category == "Medicine") %>%
filter(category == filterCategory) %>%
# Uncomment to add "missing" years when filterCategory = Economics:
# add_row(prize_year = 1901:1968, category = "Economics", prize_share=0/1) %>%
mutate(nume = as.numeric(str_sub(prize_share, 1, 1)),
deno = as.numeric(str_sub(prize_share, -1)),
share = nume/deno,
year = prize_year %% 10,
decade = prize_year - 1900 - year) %>%
group_by(prize_year) %>%
distinct(full_name, .keep_all = TRUE) %>%
mutate(n = row_number()) %>%
mutate(n = row_number()) %>%
# Big parts of plot code from https://github.com/spren9er/tidytuesday/blob/master/tidytuesday_201916_new_economist.r
ggplot() +
geom_bar(aes(x = "", y = share, fill = n),
geom_bar(aes(x = "", y = share, fill = as.factor(n)),
stat = "identity", show.legend = FALSE
) +
scale_fill_identity() +
scale_fill_brewer(palette = "Purples") +
coord_polar("y") +
facet_grid(decade ~ year) +
labs(title = "Shared Nobel Prizes in Medicine",
subtitle = "Cumulative lethal collisions, 1980-2017",
facet_grid(decade ~ year, switch = "both",
labeller = labeller(decade = decadesLabels)) +
labs(title = paste("Shared Nobel Prizes in ", filterCategory, sep = ""),
subtitle = "by decade and year, 1901-2016",
caption = "\nSource: Kaggle | Graphic: Georgios Karamanis / @geokaramanis") +
theme_void() +
theme(
plot.background = element_rect(fill = "#F0EFF1", colour = "#F0EFF1"),
plot.margin = unit(c(0.2, 0.2, 0.2, 0.6), "cm"),
text = element_text(family = "IBM Plex Sans", size = 6),
plot.title = element_text(face = "bold"),
plot.subtitle = element_text(vjust = 2)
)
plot.background = element_rect(fill = "lightgoldenrod3", colour = "lightgoldenrod3"),
plot.margin = unit(c(1.6, 0.6, 0.8, 0.8), "cm"),
text = element_text(family = "IBM Plex Sans", size = 8),
plot.title = element_text(face = "bold", vjust = 8),
plot.subtitle = element_text(vjust = 9),
plot.caption = element_text(size = 4, vjust = -3),
strip.text.x = element_text(size = 7,
margin = margin(t = 5)),
strip.text.y = element_text(size = 7,
angle = 180, hjust = 1, margin = margin(r = 10))
)

img <- paste("./week-20/nobelShared-", filterCategory, ".png", sep = "")
ggsave(img, height = 5, width = 3.64)

0 comments on commit e72d04a

Please sign in to comment.