library(data.table)
library(ggplot2)
library(scales)
library(plotly)
Electric vehicles are an increasingly common part of the automobile market, including both battery electric vehicles (BEVs) and plug-in hybrid electric vehicles (PHEVs). This report explores the current population of registered electric vehicles in Washington State.
The analysis focuses on the composition of Washington’s electric vehicle population, including vehicle type, manufacturer, model year, and electric range. Five different visualizations are used to explore patterns within the data.
The Electric Vehicle Population dataset contains information about battery electric vehicles and plug-in hybrid electric vehicles registered with the Washington State Department of Licensing. The dataset includes information such as vehicle make, model, model year, electric vehicle type, electric range, and location.
df <- fread("Electric_Vehicle_Population_Data.csv",
na.strings = c(NA, ""))
dim(df)
## [1] 138779 17
colnames(df)
## [1] "VIN (1-10)"
## [2] "County"
## [3] "City"
## [4] "State"
## [5] "Postal Code"
## [6] "Model Year"
## [7] "Make"
## [8] "Model"
## [9] "Electric Vehicle Type"
## [10] "Clean Alternative Fuel Vehicle (CAFV) Eligibility"
## [11] "Electric Range"
## [12] "Base MSRP"
## [13] "Legislative District"
## [14] "DOL Vehicle ID"
## [15] "Vehicle Location"
## [16] "Electric Utility"
## [17] "2020 Census Tract"
The original dataset contains 138,779 observations and 17 variables. Although the dataset primarily represents Washington State, a small number of records contain other state codes. For this analysis, the data was limited to vehicles with Washington listed as their state.
During the initial exploration of the data, electric range also required additional attention. There were 60,162 vehicles with an electric range recorded as 0. These records corresponded to vehicles whose Clean Alternative Fuel Vehicle eligibility was listed as unknown because the battery range had not been researched. Because these values do not represent an actual electric range of zero miles, they were treated as missing values for the electric range analysis.
df$CleanElectricRange <- df$`Electric Range`
df$CleanElectricRange[df$CleanElectricRange == 0] <- NA
WA_df <- df[df$State == "WA", ]
After limiting the dataset to Washington State, there are 138,464 registered electric vehicles included in the analysis.
table(WA_df$`Electric Vehicle Type`)
##
## Battery Electric Vehicle (BEV) Plug-in Hybrid Electric Vehicle (PHEV)
## 106585 31879
summary(WA_df$`Model Year`)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1997 2018 2021 2020 2022 2024
summary(WA_df$CleanElectricRange)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 6.0 32.0 84.0 127.7 215.0 337.0 60050
The dataset contains both battery electric vehicles and plug-in hybrid electric vehicles. The vehicles range across model years from 1997 through 2024. For vehicles with a known electric range, the median range is 84 miles and the mean is approximately 128 miles.
The first visualization examines the overall composition of electric vehicle types in Washington.
type_df <- data.frame(table(WA_df$`Electric Vehicle Type`))
colnames(type_df) <- c("VehicleType", "Count")
type_df$VehicleType <- as.character(type_df$VehicleType)
type_df$VehicleType[
type_df$VehicleType == "Battery Electric Vehicle (BEV)"
] <- "BEV"
type_df$VehicleType[
type_df$VehicleType == "Plug-in Hybrid Electric Vehicle (PHEV)"
] <- "PHEV"
plot_ly(type_df,
labels = ~VehicleType,
values = ~Count,
type = "pie",
hole = 0.6,
textinfo = "label+percent") %>%
layout(
title = "Electric Vehicle Types in Washington",
annotations = list(
text = paste0("Total EVs:<br>",
scales::comma(sum(type_df$Count))),
showarrow = F
)
)
Battery electric vehicles make up approximately 77% of the registered electric vehicles in the Washington data, while plug-in hybrid electric vehicles make up approximately 23%. This shows that fully electric vehicles represent the majority of the state’s current registered EV population.
The next visualization looks at the ten manufacturers with the largest number of registered electric vehicles. The bars are also divided by vehicle type to show how the BEV and PHEV composition differs among manufacturers.
make_count <- data.frame(table(WA_df$Make))
colnames(make_count) <- c("Make", "Count")
make_count <- make_count[
order(make_count$Count, decreasing = TRUE),
]
top10_makes <- make_count$Make[1:10]
top10_df <- WA_df[WA_df$Make %in% top10_makes, ]
top10_df$VehicleType <- top10_df$`Electric Vehicle Type`
top10_df$VehicleType[
top10_df$VehicleType == "Battery Electric Vehicle (BEV)"
] <- "BEV"
top10_df$VehicleType[
top10_df$VehicleType == "Plug-in Hybrid Electric Vehicle (PHEV)"
] <- "PHEV"
ggplot(top10_df,
aes(x = reorder(Make, Make, function(x) -length(x)),
fill = VehicleType)) +
geom_bar() +
coord_flip() +
scale_y_continuous(labels = comma) +
scale_fill_brewer(palette = "Set2") +
labs(
title = "Top 10 Electric Vehicle Manufacturers in Washington",
x = "Manufacturer",
y = "Number of Registered Electric Vehicles",
fill = "Vehicle Type"
) +
theme_light() +
theme(
plot.title = element_text(hjust = 0.5)
)
Tesla stands out as the most common manufacturer by a large margin, and its vehicles in the dataset are entirely BEVs. Other manufacturers have a more mixed composition. For example, Chevrolet and Ford have both BEVs and PHEVs, while some manufacturers are much more concentrated in one vehicle type. This shows that the EV market in Washington is not evenly distributed across manufacturers.
The third visualization examines which model years are most represented among Washington’s currently registered electric vehicles. Model years from 2010 through 2023 are shown to focus on the period containing most of the vehicles in the dataset.
year_count <- data.frame(table(WA_df$`Model Year`))
colnames(year_count) <- c("ModelYear", "Count")
year_count$ModelYear <- as.numeric(as.character(year_count$ModelYear))
year_count <- year_count[
year_count$ModelYear >= 2010 &
year_count$ModelYear <= 2023,
]
ggplot(year_count, aes(x = ModelYear, y = Count)) +
geom_line(linewidth = 1) +
geom_point(size = 2) +
scale_x_continuous(breaks = 2010:2023) +
scale_y_continuous(labels = comma) +
labs(
title = "Washington's Registered EVs by Model Year",
subtitle = "Model years 2010-2023",
x = "Model Year",
y = "Number of Registered Electric Vehicles"
) +
theme_light() +
theme(
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5),
axis.text.x = element_text(angle = 45, hjust = 1)
)
Newer model years are much more heavily represented than older model years. The number of vehicles generally rises across the model years, with 2022 and 2023 accounting for particularly large numbers of the currently registered EVs.
It is important to note that model year is not the same as registration year. Therefore, this visualization describes the model years represented in the current EV population rather than the number of EV registrations that occurred each year.
The heat map provides a closer look at how the top ten manufacturers are distributed across model years from 2015 through 2023. Darker areas represent larger numbers of registered vehicles.
heat_df <- top10_df[
top10_df$`Model Year` >= 2015 &
top10_df$`Model Year` <= 2023,
]
heat_count <- data.frame(
table(heat_df$Make, heat_df$`Model Year`)
)
colnames(heat_count) <- c("Make", "ModelYear", "Count")
ggplot(heat_count,
aes(x = ModelYear,
y = Make,
fill = Count)) +
geom_tile(color = "white") +
scale_fill_gradient(
low = "white",
high = "steelblue",
labels = comma
) +
labs(
title = "EV Manufacturers Across Model Years in Washington",
subtitle = "Top 10 manufacturers, model years 2015-2023",
x = "Model Year",
y = "Manufacturer",
fill = "EV Count"
) +
theme_light() +
theme(
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5)
)
The heat map shows that manufacturers are not represented equally across model years. Tesla has a particularly strong presence among newer model years, while the other leading manufacturers have different concentrations across the period. This provides more detail than the overall manufacturer totals by showing where those vehicles fall across model years.
The final visualization examines the distribution of known electric ranges and separates the vehicles into BEVs and PHEVs.
range_df <- WA_df[!is.na(WA_df$CleanElectricRange), ]
range_df$VehicleType <- range_df$`Electric Vehicle Type`
range_df$VehicleType[
range_df$VehicleType == "Battery Electric Vehicle (BEV)"
] <- "BEV"
range_df$VehicleType[
range_df$VehicleType == "Plug-in Hybrid Electric Vehicle (PHEV)"
] <- "PHEV"
ggplot(range_df,
aes(x = CleanElectricRange,
fill = VehicleType)) +
geom_histogram(
binwidth = 20,
color = "white",
position = "stack"
) +
scale_y_continuous(labels = comma) +
scale_fill_brewer(palette = "Set2") +
labs(
title = "Distribution of Electric Range by Vehicle Type",
subtitle = "Washington vehicles with known electric range",
x = "Electric Range (Miles)",
y = "Number of Registered Electric Vehicles",
fill = "Vehicle Type"
) +
theme_light() +
theme(
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5)
)
The distribution shows a clear difference between the electric ranges of BEVs and PHEVs. PHEVs are concentrated primarily at the lower end of the range distribution, while BEVs account for most of the vehicles with higher electric ranges. The BEV distribution also contains several noticeable concentrations at different range levels rather than one single peak.
Washington’s registered electric vehicle population is primarily made up of battery electric vehicles, with BEVs representing about three-fourths of the vehicles included in the analysis. Tesla is the most represented manufacturer, while several other major manufacturers contribute a mixture of BEVs and PHEVs.
Newer model years make up a much larger portion of the current registered EV population than older model years, and the heat map shows that manufacturer representation also varies across model years. Finally, electric range differs considerably between vehicle types, with PHEVs concentrated at lower electric ranges and BEVs accounting for most of the higher-range vehicles.
Overall, the analysis shows that Washington’s electric vehicle population differs substantially across vehicle type, manufacturer, model year, and electric range.