Skip to content

A command line program to create MLB pennant race charts.

License

Notifications You must be signed in to change notification settings

jdrem/pennant-race-charts

Repository files navigation

Pennant Race Chart Generator

This program generates pennant race charts for Major League Baseball seasons. The chart displays games above .500 in the y-axis and the date in the y-axis:

AL East 1978

Building

Build using Gradle:

./gradlew clean build copyDependencies

All the dependencies are in Maven Central

Running

You will need a source of data for the seasons you want to graph.

Retrosheet game logs are best for historical seasons. They go back to 1871 and the current year's data is usually available in December. There are available here. Download the years you're interested in and unzip them.

Current data can be downloaded from MLB's API. To get the current year's worth of data:

curl "https://statsapi.mlb.com/api/v1/scedule?sportId=1&startDate=2022-04-07&endDate=2022-10-05" > mlb-2022.json

Place the game data in the gamelogs subdirectory. By default, the program uses data in Retrosheet format. To use MLB API data, add "--data.source.type=mlbapi" to the end of the command.

Once you have the data you want, you can:

  • Run the script with just the year and get all leagues or divisions:
runPennantRaceCharts.sh 2021
  • Run the script with the year and a comma separated list of league or division abbreviations:
runPennantRaceCharts.sh 1978 ALE,ALW
  • Run the script with the year and a comma separated list of team names. You must specify a title and file name:
runPennantRaceCharts.sh 2021 BOS,NYA,TOR,SEA --title="AL Wildcard" --file.name=al_wildcard_2021.png

Divisions/Leagues can be AL, NL, ALE, ALC, ALW, NLE, NLC, NLW. NL and AL only work for 1968 and earlier, before divisions were created. NLC and ALC work only after 1993 when the central divisions were created.

The charts will be written to the top level project directory.