Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
Objective : Practically this visualization provides viewers the general price trends of Australian residential property in eight capital cities in terms of index number during recent ten years. The objective of this graph is mainly explanatory that it delivers an idea that the property price differs significantly among different cities and has changed dramatically in the past decade, which from micro contributes to a better investing decision in properties and,at a macro level, helps to analyse Australian economy with the acknowledge that property price is an indicator of macro economy.
Targeted Audience : This graph is from Australia Government webstie, it is open to broad general public. based on earlier discussion in the objective section, the targeted audience should be, but not limited to, public interested in property price and economy like potential home buyers, workers in relative industry such as real estate, and economics researching workers.
Main Issues
The visualisation chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(readxl)
library(dplyr)
library(readr)
library(knitr)
library(tidyr)
library(magrittr)
library(glue)
library(ggplot2)
library(tidyverse)
library(colorspace)
# 1 Preprocessing
d1 <- read_xlsx("/Users/noalgreen/Desktop/Tydied.xlsx")
d2 <- d1 %>% select(1:6)
d3 <- d1 %>% select(c(1,,6,7,8,9,10))
d2longer <- d2 %>% pivot_longer(2:6, names_to = "city", values_to = "index")
d3longer <- d3 %>% pivot_longer(2:6, names_to = "city", values_to = "index")
d2longerA <- read_xlsx("/Users/noalgreen/Desktop/classA.xlsx")
d2longerB <- read_xlsx("/Users/noalgreen/Desktop/classB.xlsx")
df <- rbind(d2longerA, d2longerB)
factor(df$city, levels = c("Sydney","Hobart","Melbourne","Canberra","Weighted average", "weighted average","Brisbane","Adelaide","Perth","Darwin"), ordered = TRUE)
## [1] Sydney Hobart Melbourne Canberra <NA> Sydney Hobart
## [8] Melbourne Canberra <NA> Sydney Hobart Melbourne Canberra
## [15] <NA> Sydney Hobart Melbourne Canberra <NA> Sydney
## [22] Hobart Melbourne Canberra <NA> Sydney Hobart Melbourne
## [29] Canberra <NA> Sydney Hobart Melbourne Canberra <NA>
## [36] Sydney Hobart Melbourne Canberra <NA> Sydney Hobart
## [43] Melbourne Canberra <NA> Sydney Hobart Melbourne Canberra
## [50] <NA> Sydney Hobart Melbourne Canberra <NA> <NA>
## [57] Brisbane Adelaide Perth Darwin <NA> Brisbane Adelaide
## [64] Perth Darwin <NA> Brisbane Adelaide Perth Darwin
## [71] <NA> Brisbane Adelaide Perth Darwin <NA> Brisbane
## [78] Adelaide Perth Darwin <NA> Brisbane Adelaide Perth
## [85] Darwin <NA> Brisbane Adelaide Perth Darwin <NA>
## [92] Brisbane Adelaide Perth Darwin <NA> Brisbane Adelaide
## [99] Perth Darwin <NA> Brisbane Adelaide Perth Darwin
## [106] <NA> Brisbane Adelaide Perth Darwin
## 10 Levels: Sydney < Hobart < Melbourne < Canberra < ... < Darwin
# 2 Plotting_2.1 Main lines and points and plot anatomy
p1 <- df %>% ggplot() +
geom_line( aes(x = Year, y = index, colour = city, group = city)) +
geom_point( aes(x = Year, y = index, colour = city, group = city,shape = city)) +
scale_shape_manual(values = c(Sydney = 1, Hobart = 3, Melbourne = 3, Canberra = 4, `Weighted average` = 5, `weighted average` = 5, Brisbane = 6, Adelaide = 7, Perth = 8, Darwin = 9)) +
facet_wrap( ~class, 2) +
scale_x_continuous(breaks = seq(2011,2021,1)) +
scale_y_continuous(breaks = seq(50,250,25)) +
scale_colour_manual(values = c(Sydney = "#0033FF", Hobart = "#660099", Melbourne = "#009933",Canberra = "#663300", `Weighted average` = "#CCCCCC", `weighted average` = "#CCCCCC", Brisbane = "#996633", Adelaide = "#9900FF", Perth = "#00FF99", Darwin = "#FFCC33")) +
labs(title = "Residential Property Price Index of Australian Capital Cities",
x = "Years", y = "Index Number", caption ="Source: Australian Bureau of Statistics")
# 2_Plotting_2.2 Theme setting
axis_theme<-theme(
axis.title=element_text(face = "bold.italic",colour = "dark blue", size = 15, hjust = .5, vjust = .5, angle = 0),
axis.text=element_text(face = "italic", size = 10, colour ="blue"),
axis.ticks=element_line(colour="blue", size=.5, linetype=1, lineend=1),
axis.ticks.length=unit(.4,"lines"),
axis.ticks.margin=unit(.4,"cm"),
axis.line=element_line(colour="black"))
title_theme <- theme(plot.title = element_text(face = "bold", colour = "dark blue", size = 15, hjust = 0.5))
grid_theme <- theme(panel.border = element_blank(),
panel.background = element_rect(fill = "white", color = NA),
panel.grid.major = element_line(size = 0.5, linetype = 'dotted',
colour = "black"),
panel.grid.minor = element_line(size = 0.05, linetype = 'dotted',
colour = "black"),
strip.text = element_text(face = "bold", colour = "blue", size = 15, hjust = 0.5))
p2 <- p1 +
axis_theme +
title_theme +
grid_theme
# 2_Plotting_Add annotations
p3 <- p2 + annotate(
geom = "curve", x = 2017, y = 150, xend = 2017, yend = 200,
curvature = .3, arrow = arrow(length = unit(2, "mm"))
) +
annotate(geom = "text", x = 2017, y = 210, label = "weighted average as benchmark")
p3
Data Reference
The following plot fixes the main issues in the original.