Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of this data visualisation is to provide a top level snapshot of Federal Government expense estimates by year and function. The target audience for this information is the general public.
The visualisation has the following three main issues:
The use of a stacked bar chart makes it difficult to compare spending by function as only one of the functions shares a common base line. As a result, the only meaningful comparisons that can made are for the Social Security and Welfare function and for total spending. Additionally, there are too many categories for this type of visualisation. The reader has to keep moving between the bar chart and the legend to interpret which function each of the colours relate to which can be frustrating.
There are several data anomalies between the visualisation and the source data. For example, the visualisation shows General Revenue Assistance as $64.1b for 2020-21 but the budget paper lists $61.9b. Also, functions aren’t represented in accordance with the listed budget function categories (i.e. 9 of the functions are missing from this visualisation). The author has instead chosen to include several unrelated expenses outside of the function areas (e.g. General Revenue Assistance and Public Debt Interest).
Some of the aesthetic choices are confusing. For example, it is difficult to distinguish between the two darker colours in the legend, and some of the functions within the stacked bar chart are missing value labels. Also, the pale grey colour assigned to General Revenue Assistance is too light and is difficult to see against the white background.
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
library(stringr)
estimates <- read.csv("C:/Users/Jason/Desktop/Grad Cert Data Science/3. Data Visualisation/Assessment 2/Estimates by Function_archive.csv")
#convert categorical data
estimates$Function<-as.factor(estimates$Function)
estimates$Year<-as.factor(estimates$Year)
# assign levels for Years
estimates$Year<-factor(estimates$Year,
levels=c('2018-19', '2019-20', '(e)2020-21', '(e)2021-22', '(e)2022-23', '(e)2023-24'),
ordered=TRUE)
# assign levels for Functions - highest spend to lowest, with Total Expenses last
estimates$Function<-factor(estimates$Function,
levels=c('Social security and welfare', 'Other purposes', 'Other economic affairs', 'Health', 'Economic Response to Covid-19', 'Education', 'Defence', 'General public services', 'Transport and communication', 'Fuel and energy', 'Housing and community amenities', 'Recreation and culture', 'Public order and safety', 'Mining, manufacturing and construction', 'Agriculture, forest and fishing','Total expenses'),
ordered=TRUE)
#plot the data
plot<-ggplot(data=estimates, aes(x=Year, y=X.b))+
facet_wrap(~Function, ncol=4, scales='free_y', labeller=labeller(Function = label_wrap_gen(20)))+
scale_y_continuous(limits=c(0,NA))+
geom_point(colour=ifelse(estimates$Year=="2018-19","grey28", ifelse(estimates$Year=="2019-20", "grey28", "blue")))+
geom_line(aes(group = 1), colour="blue")+
labs(x="Year",
y="$b",
title="Government Spending by Function",
subtitle="Past Actuals and Future Estimates")+
theme_bw()+
theme(axis.text.x = element_text(angle = 45, size=10, vjust = 0.5, hjust=0.5),
axis.text.y = element_text(size=10),
strip.text.x=element_text(size=12),
strip.background = element_rect(fill="wheat"),
axis.title=element_text(size=14, face='bold'),
plot.title= element_text(size=16, face='bold'),
plot.subtitle=element_text(size=14, face='italic'),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())+
geom_rect(aes(xmin=0.5,
xmax=2.5,
ymin=-Inf, ymax=Inf), fill="grey47", alpha=.05)+
geom_text(aes(label=round(X.b,1)), size = 3, vjust = 1.5)
Data Reference
Australian Government, 2019. Budget Strategy and Outlook: Budget Paper No. 1: 2019-20. Retrieved July 23, 2021, from Parliament of Australia website: https://parlinfo.aph.gov.au/parlInfo/download/library/budget/2019_4/upload_binary/bp1.pdf;fileType=application%2Fpdf#search=%22library/budget/2019_4%22
Australian Government, 2020. Budget Strategy and Outlook: Budget Paper No. 1: 2020-21. Retrieved July 23, 2021, from Parliament of Australia website: https://parlinfo.aph.gov.au/parlInfo/download/library/budget/2020_001/upload_binary/bp1_w.pdf;fileType=application%2Fpdf#search=%22budget%20strategy%20and%20outlook%22
The following plot fixes the main issues in the original.