Objective
The original visualisation is a multivariate Coxcomb chart that illustrates the distinct waves of the opioid epidemic in the US and demonstrating the consequential increase in deaths due to Heroin, Pharmaceutical or synthetic opioids.The author intends to highlight the influence of specific waves/events in the history of opioids resulting in increase of overdose deaths to a general adult audience, healthcare workers and opioid users.
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
library(tidyr)
data2 <- read.csv('C:/Users/Admin/Desktop/2022/RMIT/Data Visualisation/A2/data2.csv')
long_data2 <- gather(data2, "opioid", value ='Deaths', Heroin:Synthetic, factor_key =TRUE)
long_data2$Year <- factor(long_data2$Year, levels = c('1999','2000', '2001', '2002', '2003',
'2004', '2005', '2006', '2007', '2008', '2009', '2010',
'2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018'),
labels = c('1999','2000', '2001', '2002', '2003',
'2004', '2005', '2006', '2007', '2008', '2009', '2010',
'2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018'))
fig3 <- ggplot(long_data2, aes(x = Year, y= Deaths, fill = wave, color = 'Black'))+
geom_bar(stat = 'identity',width = 1, colour = "black", position = 'stack')+
scale_fill_manual(values = c("#EE442F", "#601A4A","#63ACBE"), labels = c("Wave 1 (overpresecription of opioids for pain relief)",
"Wave 2 (Heroin-related overdose deaths on the rise)",
"Wave 3 (Synthetic-related overdose deaths on the rise)"))+
facet_wrap(~long_data2$opioid, nrow = 1, ncol =3)+
labs (title="Opioid overdose deaths in the U.S.",x = 'Year', y = 'Deaths',
caption = "Source: https://www.visualcapitalist.com/the-spiraling-opioid-epidemic-in-america/")+
theme(legend.position="top",
legend.title = element_blank(),
legend.background = element_rect(fill = "darkgray"),
legend.direction = "vertical",
legend.text = element_text(size=12,face="bold"),
plot.title = element_text(size=16,face="bold",hjust=0),
plot.subtitle = element_text(size=13,face="bold",hjust=0),
plot.caption = element_text(face="italic"),
strip.text.x = element_text(size=12,face="bold")
) + coord_flip()
Data Reference
The following plot fixes the main issues in the original.