Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.
Objective
Targeted Audience
The visualization chosen had the following three main issues:
No Basic visualization Conventions:
Difference between the price for insurance cover:
Comparing the price difference and state abbreviation:
Reference
The following code was used to fix the issues identified in the original.
library(ggplot2)
library(readr)
insurance <- read_csv("insurance_1.csv")
my_cols1 <- c("Full coverage", "Minimum coverage")
insurance$Price_diff <- do.call(paste, c(insurance[my_cols1], sep = "-"))
# combine the price diff column and state
my_cols <- c("State", "Price_diff")
insurance$Price_state <- do.call(paste, c(insurance[my_cols], sep= " "))
# remove the reamining columns
insurance <- insurance[, ! colnames(insurance) %in% c(my_cols, my_cols1)]
p1 <- ggplot(insurance, aes(x = Difference, y = reorder(Price_state,Difference),)) + geom_col(fill = '#003366', color = 'red')+ geom_text(aes(label = Difference, vjust = 1,
hjust = 0))+
theme(axis.text.y = element_text(size = 9), plot.title = element_text(size = 12,face = "bold"), axis.text=element_text(size=8, face = "bold"),
axis.title=element_text(size=10,face="bold"))+
labs(title = "The difference in price for car insurance cover in each state",
x = "Price Difference $(Full cover - Minimum Cover)",
y = "Insurance Price Per State(Full cover , Minimum Cover)")
Data Reference
The following plot fixes the main issues in the original.