I have a dataset showing data on all tornadoes that have happened in the US between 1950-2020. I would like to make a barplot showing the total count of tornados by state (st).
First, I got the sum of tornadoes by state using:
statecount = dplyr::count(tornadodata, st, sort = TRUE)
So the data now looks like this (there's 53 total rows): raw data
And then I attempted to plot this using:
barplot(statecount$n, yaxt = "n")
axis(side=2, las=1, at=seq(0, 10000, by=1000))
This was the result:
I can tell that the graph itself is correct, but I don't know how to get the states to show up on the x axis? I've tried reducing the font size using cex.axis
, and also tried rotating the labels using las=2
inside the plot(n)
call, but these haven't worked. Just as a test, I tried plotting only the top 5 states using:
barplot(head(statecount, 5)$n)
And still the x axis didn't show up. Not sure what I'm doing wrong here, any pointers would be much appreciated.
Data in dput
format
statecount <- structure(list(
st = c("TX", "KS", "OK", "FL", "NE", "IA", "IL", "MS", "MO", "AL"),
n = c(9055L, 4338L, 4029L, 3464L, 2923L, 2654L, 2609L, 2401L, 2381L, 2293L)),
row.names = c(NA, 10L), class = "data.frame")