This is a template file. The example included is not considered a good example to follow for Assignment 2. Remove this warning prior to submitting.
Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
The objective of this data visualization is to compare the annual inflation rate changes of USA and Sweden over time. And compare how the inflation rate has changed due to the covid pandemic. And also this visualization helps the audience to predict how the economy of USA and Sweden will behave relative to each other in future. Also this visualization gives an idea about which of these countries has the more stable economy. Target audience for this data visualization is borrowers, lenders, investors, businessmen etc. Because borrowers and lenders can use the behavior of the inflation rate to increase their profits. And investors can decide in which country are they going to invest their money in future. And businessmen can make new strategies to improve their businesses according to the inflation rate changes.
The visualization chosen had the following three main issues:
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
df <- read.csv("done.csv")
p1 <- ggplot(data=df,aes(x=year,y=inflation, group=country))
p1 <- p1+ geom_line(aes(color=country), size=1)
p1 <- p1+ scale_color_manual(values=c("#5daee8","#e0db38"))
p1 <- p1+ labs(title="Inflation rates vs years", x="year",y="Inflation Rate")
p1 <- p1+ theme_classic(base_family = "serif")
p1 <- p1+ theme(aspect.ratio=9/16)
p1 <- p1+ theme(plot.title = element_text(hjust = 0.5, size=20), axis.title.y=element_text(size=15), axis.title.x=element_text(size=15))
p1 <- p1+ theme(
legend.title = element_text(size=14),
legend.text = element_text(size=13),
legend.box.background = element_rect(colour = "black"))
p1 <- p1+ scale_x_continuous(limits=c(2010,2025), breaks=scales::breaks_width((1)))
p1 <- p1+ scale_y_continuous(limits=c(-0.5,6), breaks=scales::breaks_width((0.5)))
p1 <- p1+ geom_hline(yintercept=0, linetype="solid", color = "#329629")
p1 <- p1+ geom_vline(xintercept=2020, linetype="solid", color = "red")
p1 <- p1+ geom_text(aes(2016,4,label="Before Covid Pandamic"), size=4)
p1 <- p1+ geom_text(aes(2023,4,label="After Covid Pandamic"), size=4)
Data Reference
The following plot fixes the main issues in the original.