SVGZ Graphic: Best selling Christmas Singles

Download the Scalable Vector Graphic of the Best selling Christmas Singles.

About SVGZ Graphic: Best selling Christmas Singles ....

Further evidence that Christmas music is pretty awful based on what people are parting with their hard-earned cash to download legally from the interwebs. Plus a fun exercise in webscrapping with Wikipedia to make a graph.

library(rvest)
library(tidyverse)

music <- read_html('https://en.wikipedia.org/wiki/List_of_best-selling_Christmas_singles_in_the_United_States')

table <- music %>% html_table()

table[[1]]$`Digital downloads`=as.numeric(gsub("(\[.*|,)","", table[[1]]$`Digital downloads`))
table[[1]]$`Artist` = gsub("\(.*","", table[[1]]$`Artist`)

ggplot(table[[1]], aes(x=table[[1]]$`Digital downloads`, y=reorder(paste(table[[1]]$Title,table[[1]]$Artist,sep="n"), -table[[1]]$`Digital downloads`),
                       fill=table[[1]]$Rank)
       ) + geom_col() + geom_label(aes(label=scales::comma(table[[1]]$`Digital downloads`)),hjust='right', size=6, fill='white', nudge_x = -20000) +
  scale_x_continuous(labels = scales::comma_format(scale=1/1000000, suffix='m'), expand=c(0,0), breaks=seq(0,3,0.5)*1000000) +
  scale_fill_gradient2(low='darkred', high='darkgreen', midpoint=mean(table[[1]]$Rank)) +
  labs(title = 'Best-selling Christmas singles',
       subtitle='',
       caption='Wikipedia/Nielsen SoundScan began trackingndigital download sales data at the end of June 2003. ',
       tag=paste('Andy Arthur,', format(Sys.Date(), format="%m/%-d/%y")),
       x='Digital Downloads',
       y='',
       fill = "", ) +
  theme_bw() +
  theme(
    text= element_text(family='Overpass',size=14),
    plot.title=element_text(hjust=0.5, face='bold',size=28),
    plot.background = element_rect(fill = "white", color="white"),
    plot.subtitle=element_text(hjust=0.5),
    plot.tag=element_text(size=10,hjust=0, color='#555555'),
    plot.caption=element_text(size=10, color='#555555'),
    plot.margin = unit(c(1,1,1,1), 'lines'),
    plot.tag.position = c(0.0,0.01),
    legend.position = 'None',
  )

ggsave(paste('/tmp/christmas.svg',sep=''), width=1920, height=1080, units='px', dpi=150, device = grDevices::svg)

More about Christmas Time...

Leave a Reply

Your email address will not be published. Required fields are marked *