This visualization plots each state (plus the District of Columbia) as a blue dot in a scatterplot.
The X axis displays how far the house price index in the state is from its pre-2008 peak. A vertical line at 100% indicates that the price index for that state is exactly at the pre-2008 peak for that state. If the value is to the right (left) of the vertical line, then the index is above(below) that peak.
The Y axis displays how far the index is from the post-2007 minimum for that state. The horizontal line at 100% indicates that the state is exactly at that minimum. As states recover from the post-recession bottom, they move further up on the chart.
A value at (75%, 125%) would indicate that the state is only 75% of the pre-2008 maximum, and 125% of the post-2007 minimum.
You can see that North Dakota (ND) does not fall much during the Great Recession and recovers quickly. California (CA) and Florida (FL) fall a lot, but have a strong recovery.
Making the chart
The data for the charts can be found at the following links:
Constructing this chart is fairly straightforward. We simply have to calculate the pre-2008 peak and post-2007 minimum for each state. As I mentioned in Part 1: data wrangling , I already computed the pre-2008 peak value and post-2007 minimum value for each state and added it as an additional variable. Elegant and efficient? No, but it will get this job done.
Now to make this animation, I set up a function to contain my ggplot code. Because this code is so simple, it’s not really necessary. But it could be helpful to have a function down the line.
The function takes a year value yy and a month value mm and creates the bubble plot for that year and month combination.
Labels for scatterplot
My favorite part of this plot was using the ggrepel package to create the labels for the scatterplot. If you’ve ever tried to label a scatterplot or bubble chart with lots of points you should really appreciate this package, which handles labels automatically. It’s an incredible time saver preventing you from having to manually adjust the point labels. And in an animation, it’s would consume enormous time to try to move all the labels for each image. Unless you have an intern or RA, then this package is a must-use.
Now we’re going to use the metro data to analyze seasonality in house prices:
Explaining the plot
I think this animation does a good job of displaying seasonality in house prices. I’ve color coded the dots so that they fade from blue in January to red in June back to blue in December. As housing markets heat up and prices rise, the colors shift redder and fade bluer as prices rise. The dots bounce up and down in fairly close unison, but like popcorn in a popper, some jump up more than others.
The code for this one is pretty straightforward if you’ve been following along:
That’s it for today’s meditations, but we’ll have more in the future. Up next: SWOOOSH!!!