This web page features a plot created with Plotly. The goal of this assignment is to demonstrate the ability to host an interactive visualization on RPubs that includes a current date and reproducible code.
In this section, we visualize the impact of severe weather events on public health. Unlike a static plot, you can hover over the bars below to see exact values, zoom into specific areas, or toggle categories on and off using the legend.
# Data Preparation
weather_data <- data.frame(
Event = c("Tornado", "Excessive Heat", "Flood", "Flash Flood", "Lightning", "TSTM Wind"),
Fatalities = c(5633, 1903, 470, 978, 816, 133),
Injuries = c(91346, 6525, 6789, 1777, 5230, 1488)
)
# Creating the interactive Plotly Bar Chart
fig <- plot_ly(weather_data,
x = ~reorder(Event, -Injuries),
y = ~Injuries,
type = 'bar',
name = 'Injuries',
marker = list(color = 'rgba(255, 153, 51, 0.7)',
line = list(color = 'rgba(255, 153, 51, 1.0)', width = 1.5)))
fig <- fig %>% add_trace(y = ~Fatalities,
name = 'Fatalities',
marker = list(color = 'rgba(204, 0, 0, 0.7)',
line = list(color = 'rgba(204, 0, 0, 1.0)', width = 1.5)))
fig <- fig %>% layout(
title = "Health Impact of Severe Weather (Total Counts)",
xaxis = list(title = "Weather Event Type"),
yaxis = list(title = "Number of Persons Affected"),
barmode = 'group',
hovermode = "x unified")
fig
The interactive chart above highlights that while Tornadoes cause the highest number of injuries, Excessive Heat remains a significant threat to life. Using Plotly allows users to explore these data points in greater detail than standard static visualizations.
Date of Document Creation: r format(Sys.Date(), “%B %d, %Y”)