avg_aqi_city <- top5_cities %>%
  group_by(city_ascii) %>%
  summarize(avg_aqi = mean(aqi, na.rm = TRUE))

plot_ly(
  data = avg_aqi_city,
  x = ~city_ascii,
  y = ~avg_aqi,
  type = 'bar',
  text = ~paste("Average AQI:", round(avg_aqi,1)),
  hoverinfo = 'text',
  marker = list(color = 'rgba(22, 96, 167, 0.6)',
                line = list(color = 'rgba(22, 96, 167, 1.0)', width = 1.5))
) %>%
  layout(
    title = "Average AQI by City",
    xaxis = list(title = "City"),
    yaxis = list(title = "Average AQI")
  )
top5_cities %>%
  ggplot(aes(x = city_ascii, y = aqi, fill = city_ascii)) +
  geom_boxplot(alpha = 0.7) +
  scale_fill_brewer(palette = "Set2") +
  labs(
    title = "Distribution of AQI by City",
    x = "City",
    y = "AQI"
  ) +
  theme_minimal() +
  theme(legend.position = "none")