As a data geek, it’s hard not to be drawn in by a sport like Major League Baseball with such rich statistics readily available. I wasn’t very interested in the game until I discovered how simple it is to collect and analyze data on every player, pitch and play. This dashboard is the result of my discovery:
Getting the Data
All the data for this viz comes from PITCHf/x, a tracking system installed in every MLB stadium. Fangraphs has an excellent overview of it and how to interpret the data.
An easy way to get data in bulk is the pitchRx package for R by Carson Sievert. I followed the examples he gave for downloading it into a SQLite database. You will need to install a SQLite ODBC driver to get it from there into Tableau.
Bonus Tip: Smooth Colors With Halftone Custom Shapes
To create the heat map, I used a custom shape that provides a smooth transition between differently-colored overlapping marks. Since Tableau doesn’t recognize gradient transparency in custom shapes, we can use halftones (altering the size and spacing of small dots) to achieve the same result. This concept was first used in black-and-white printing to create the impression of gray scales. In Tableau, it creates a “fade” effect on each mark.
The pitching visualization uses the circular halftone below. Download the image and follow the steps here to use it in your own dashboards.