Visualizing Philadelphia's Crime With Animated GIFs

I recently began experimenting with making animated GIFs in R. This process is surprisingly easy with the ggplot2 extension gganimateI have found that animated plots or maps can be very effective tools to demonstrate time-series patterns in data and can be a great alternatives to small multiples or 3D plots.

I chose to experiment with gifs using crime data for the City of Philadelphia from 2007-2016. I was interested in the time-space trends in crime, specifically how crime-frequency varies by time of day in different parts of the city. After spatially joining each crime incident to a census tract, I used dplyr to summarize by tract and hour of the day. 

After some wrangling, I had a dataset of the total number of incidents in all categories of crime for each tract in each hour of the day. I then created two animated plots and arranged them into the following data visualization:

Interestingly, I didn't see the nighttime spike in crimes that I would have expected. I suspected this to be the case because of the broad range of crime types I had included. I re-created the same visualization but this time only including alcohol-related crimes:

And again with just violent crimes:


There is a predictable spike alcohol-related crimes at night (when most drinking occurs) but interestingly we don't see the same pattern for violent crimes.