Submitted by TrueBirch t3_zfcoks in dataisbeautiful
TrueBirch OP t1_izb47vx wrote
Reply to comment by TrueBirch in Swans: The ultimate gift from your true love [OC] by TrueBirch
library(tidyverse)
price <- tibble(item_name = c("12 Partridges in a Pear Tree", "22 Turtle Doves", "30 French Hens",
"36 Calling Birds", "40 Gold Rings", "42 Geese a-Laying", "42 Swans a-Swimming",
"40 Maids a-Milking", "36 Ladies Dancing", "30 Lords a-Leaping",
"22 Pipers Piping", "12 Drummers Drumming"),
total_cost = c(3362.16, 6600, 3187.5, 5399.64, 9960, 5040, 78749.58, 290,
33232.48, 41940, 6042.8, 3266.93)) %>%
mutate(total_cost_rounded = scales::dollar(round(total_cost)))
price$item_name_ordered <-
ordered(price$item_name, levels = price$item_name)
ggplot(price, aes(x = item_name_ordered, y = total_cost, fill = "#D6001C")) +
geom_col() +
geom_label(aes(label = total_cost_rounded),
position = position_stack(
vjust = 0.5)) +
coord_flip() +
labs(
title = "Total cost of each gift in the song \"The 12 Days of Christmas\"",
y = "Total cost of each item in the United States in 2022",
x = NULL,
caption = "Created by TrueBirch using data from PNC's Christmas Price Index.
Total cost is the unit cost multiplied by number of times a gift is given."
) +
scale_y_continuous(label = scales::dollar) +
scale_fill_manual(values = "#D6001C") +
theme(
panel.grid.major = element_line(colour = "gray60"),
panel.grid.minor = element_line(colour = NA),
panel.grid.major.y = element_blank(),
panel.background = element_rect(fill = "#599C5D"),
plot.background = element_rect(fill = "gray93"),
legend.position = "none",
plot.title = element_text(size = 17),
plot.caption = element_text(size = 11),
axis.title = element_text(size = 13),
axis.text = element_text(size = 12),
strip.text = element_text(size = 12)
)
Macrophage87 t1_izbf2f3 wrote
Eew hardcodes
TrueBirch OP t1_izbf9gr wrote
Easiest way to share code without any external dependencies
Viewing a single comment thread. View all comments