Let me guess. You love baseball. You’re probably a sabermetrics nerd. You might even keep your own baseball blog. You know about PITCHf/x, but don’t have the resources or computing chops to put it to use. If so, you’re in the right place. PITCHf/x visualization is now easier than ever (and free) thanks to pitchRx and shiny.

A web hosted version of this tool is available here. However, in order to create animations, you’ll need to run the local version. To run the local version, first install R, then enter the following into your R console:

install.packages("shiny")
library(shiny)
shiny::runGitHub('shiny_apps', 'cpsievert', subdir='pitchRx')

This should eventually open your default web browser. Your browser page should look similar to the screenshot below. (I built this using Firefox, if you are running into problems with your browser, please notify me and/or consider using Firefox)

By default, the sample dataset in pitchRx is loaded. However, there is an option to upload any csv file from your local machine (if you don’t have data, but want some, see my post about obtaining PITCHf/x data).

This tool is exciting because you can generate complicated plots quickly and download them for later use (just click the “Download Current Plot” button). I don’t consider myself a baseball analyst, but I would love to see those of you using this work to complement your analyses (please cite pitchRx and/or this post).

Here is a short explanation of what is currently possible with this tool:

First, consider plotting options that apply to any plotting method listed below. These “universal” options include: choosing x-axis and y-axis limits as well as column and/or row-wise facetting.

  1. Animation of flight paths. Options include choice of different coloring variables.
  2. Visualization of strikezones. In this case, there are options that apply to any of the four plotting geometries. These options include: adding contour lines to the current plot as well as adjustment of vertical locations according to aggregate strikezones (ie, average heights).
    1. Using a “point” geometry: Options include choice of different coloring variables.
    2. Using a “tile” geometry: Options include altering density definitions.
    3. Using a “hex” geometry: Options include altering density definitions as well as adjustment of hex heights and widths.
    4. Using a “bin” geometry: Options include altering density definitions as well as adjustment of bin heights and widths.

Altering density definitions is probably my favorite feature. It allows one to examine differences between two different strikezone densities. Since it’s difficult to do this visually, pitchRx provides the basis for plotting differenced densities. For example, one may want to subtract the density of “Balls” from “Called Strikes” to explore umpire influence:

Lastly, have fun and let me know what you think!