Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Source: Visual Capitalist(2022)
Objective
In the visualisation, we can see the stock price changes of companies involved in the COVID-19 Vaccine business from 2020 to 2021.
The visualisation chosen had the following three main issues:
In this visualisation, the color selection is poor, which makes it difficult for the audience to understand what the plot is about. In this case, it appears that the same shade of blue is being used for multiple variables, making interpretation difficult.
Numerous points on the line are hidden due to the overlap of the charts. Johnson-Johnson graph, for instance, is largely hidden by Novavax.
Over the course of a year, the visual shows the stock prices of eight companies. Concentrating on the information is difficult since there are so many factors to analyze.
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
library(dplyr)
library(readr)
#Reading thefiles
JJ<- read_csv("C:/Users/Admin/Downloads/JJ.csv")
CC<- read_csv("C:/Users/Admin/Downloads/Curevac.csv")
PR<- read_csv("C:/Users/Admin/Downloads/Pfizer.csv")
BT<- read_csv("C:/Users/Admin/Downloads/BioNtech.csv")
MA<- read_csv("C:/Users/Admin/Downloads/Moderna.csv")
AZ<- read_csv("C:/Users/Admin/Downloads/Astrazeneca.csv")
SC<- read_csv("C:/Users/Admin/Downloads/Sinovac.csv")
NX<- read_csv("C:/Users/Admin/Downloads/Novavax.csv")
#Converting it into date class
JJ$Date <- as.Date(JJ$Date, format= "%b %d, %Y")#Stackoverflow
CC$Date <- as.Date(CC$Date, format= "%b %d, %Y")#Stackoverflow
PR$Date <- as.Date(PR$Date, format= "%b %d, %Y")#Stackoverflow
BT$Date <- as.Date(BT$Date, format= "%b %d, %Y")#Stackoverflow
MA$Date <- as.Date(MA$Date, format= "%b %d, %Y")#Stackoverflow
AZ$Date <- as.Date(AZ$Date, format= "%b %d, %Y")#Stackoverflow
SC$Date <- as.Date(SC$Date, format= "%b %d, %Y")#Stackoverflow
NX$Date <- as.Date(NX$Date, format= "%b %d, %Y")#Stackoverflow
#renaming the columns
colnames(SC)[6]<-'Closing_Price'
colnames(CC)[6]<-'Closing_Price'
colnames(NX)[6]<-'Closing_Price'
colnames(PR)[6]<-'Closing_Price'
colnames(BT)[6]<-'Closing_Price'
colnames(MA)[6]<-'Closing_Price'
colnames(JJ)[6]<-'Closing_Price'
colnames(AZ)[6]<-'Closing_Price'
p1 = ggplot() +
geom_line(data = NX, aes(x = Date, y = Closing_Price), colour="aquamarine4", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations for Novavax') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") + #Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"), #Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p2 = ggplot() +
geom_line(data = JJ, aes(x = Date, y = Closing_Price), colour="blue", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of Johnson-Johnson') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") + #Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1),#R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p3 = ggplot() +
geom_line(data = MA, aes(x = Date, y = Closing_Price), colour="Purple", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of Moderna') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") + #Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p4 = ggplot() +
geom_line(data = BT, aes(x = Date, y = Closing_Price), colour="green", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of BioNtech') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +#Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p5 = ggplot() +
geom_line(data = CC, aes(x = Date, y = Closing_Price), colour="red", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of Curevac') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +#Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p6 = ggplot() +
geom_line(data = PR, aes(x = Date, y = Closing_Price), colour="#4393C3", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of Pfizer') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +#Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
p7 = ggplot() +
geom_line(data = SC, aes(x = Date, y = Closing_Price), colour="turquoise4", size = 1) +
labs(y = 'Price', title = 'Covid-19-vaccine-stock-prices-oscillations of Sinovac') +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +#Cran r project
theme(axis.text.x=element_text(angle = 45, hjust = 1), #R Bloggers
panel.background = element_rect(fill = "white"),#Datanovia
panel.grid.minor = element_line(size = (0.2), colour="grey"), # Rstudio Community
panel.grid.major = element_line(colour ="grey",size = (0.1)), # Rstudio Community
plot.background = element_rect(fill = "#BFD5E3"), #Datanovia
text = element_text(family = 'base_family', face = "plain", colour = "black"), #Github
axis.text = element_text(colour = "black"))
Data Reference
Alboukadel, ’ GGplot theme background color and grids’, Datanovia,viewed 23 October 2022 https://www.datanovia.com/en/blog/ggplot-theme-background-color-and-grids/
Bradley Saul 2017,‘Errors with element_text when setting axis.text.x/y after theme_void()’,Github, https://github.com/tidyverse/ggplot2/issues/2242viewed 27 October 2022
Erasmus Tyapa 2021,‘Adding a legend on multiple line plot’, Rstudio Community,viewed 23 October 2022 https://community.rstudio.com/t/adding-a-legend-on-multiple-line-plot/103011
Finnstats 2021,‘How to Rotate Axis Labels in ggplot2?’, R Bloggers, https://www.r-bloggers.com/2021/09/how-to-rotate-axis-labels-in-ggplot2/viewed 29 October 2022
Mdsumner 2010, ‘Convert character to class Date’, Stackoverflow, viewed 22 October 2022 https://stackoverflow.com/questions/4310326/convert-character-to-class-date
Steve Condylios, Cran r project,viewed 31 October 2022 https://cran.r-project.org/web/packages/priceR/readme/README.html
The following plot fixes the main issues in the original.