The Data

The data this week comes from US DOT. An interactive map can be used at https://www.arcgis.com/home/webmap/viewer.html?panel=gallery&layers=cc51698ab9d94d67b4ec5dc5b8d97f34 with a short article from the EIA.

Hattip to Data is Plural for sharing this resource.

stations <- read_csv("stations.csv") %>%
  janitor::clean_names() %>%
  mutate(year = lubridate::year(as.Date(open_date))) %>%
  mutate(decade = (year%/%10)*10)
text <- c("BD: Biodiesel (B20 and above)",
"CNG: Compressed Natural Gas",
"ELEC: Electric",
"E85: Ethanol",
"HY: Hydrogen",
"LNG: Liquefied Natural Gas",
"LPG: Propane")
text <- paste0(text, collapse = "\n")
text.df <- data.frame(text)

Fuel stations established over time

stations %>%
  filter(!(state %in% c("AK", "HI", "ON", "PR"))) %>%
  filter(!is.na(state)) %>%
  filter(status_code == "E") %>%   # station is available
  filter(latdd > 22) %>%  # seems like there are some outliers
  ggplot(aes(color = fuel_type_code)) + 
  geom_point(aes(x = longdd, y = latdd), size = .5) +
  facet_wrap(~fuel_type_code) +
  gganimate::transition_time(year, range = c(1980, 2022)) + 
  gganimate::shadow_mark(past = T, future = T, alpha = 0.6) +
  theme_void() +
  theme(legend.position="none") +
  labs(
    title = "Evolution of alternative fuel stations over time",
    caption = "Tidy Tuesday Plot: @hardin47 | Data: US DOT via Data is Plural") 

  grid::grid.text(
    x = .5,
    y = .2,
    label = text,
    gp = grid::gpar(fontsize = 18, fontface = "bold", 
                    fontfamily="mono")
  )

Fuel stations

The animation should look like this (at the end). I’m not sure why the electric vehicles aren’t showing up in the animated version fo the plot.

stations %>%
  filter(!(state %in% c("AK", "HI", "ON", "PR"))) %>%
  filter(!is.na(state)) %>%
  filter(status_code == "E") %>%   # station is available
  filter(latdd > 22) %>%  # seems like there are some outliers
  ggplot(aes(color = fuel_type_code)) + 
  geom_point(aes(x = longdd, y = latdd), size = .5) +
  facet_wrap(~fuel_type_code) +
  theme_void() +
  theme(legend.position="none") +
  labs(
    title = "Alternative fuel stations across the US",
    caption = "Tidy Tuesday Plot: @hardin47 | Data: US DOT via Data is Plural") 
  grid::grid.text(
    x = .5,
    y = .2,
    label = text,
    gp = grid::gpar(fontsize = 18, fontface = "bold", 
                    fontfamily="mono")
  )