Note: Click visuals for larger picture
Ever since I was a little kid, basketball has been a big part of my life.
When the National Basketball Association(NBA) cancelled the remainder of its 2019-2020 season, due to COVID-19, I was extremely disappointed.
Inspired by posts by Kirk Goldsberry and a LA Times graphic about Kobe Bryant’s career shots, I decide to visualize the growth of an NBA player through his shot charts. I thought this project would help fill the void in my life caused by the lack of NBA basketball.
In a reality, without COVID, NBA playoff games would be occuring right now!
The visualizations above are the shots attempted by Giannis Antetokounmpo during all his regular season games.
The data used to create the visuals were extracted using a script written in the Python1 programming language with the help of a NBA API Client package called “nba_api”. nba_api is an API Client for the official NBA website that contains various api endpoints that can provide specific NBA data to the user. More examples of usage can be found here.
Specifically I used the endpoint ‘shotchartdetail’ to access my data. Shotchardetail allowed me to access NBA stats data that had recorded shot locations and shot distances (units = ft.) for every shot a player took during a specific NBA season. With the help of the Pandas2 python package the same script was used to clean and extract the necessary shot location data columns (x,y) in the form of a Pandas DataFrame. I was lucky to have found this api, because most of the NBA datasets I found did not have location data.
For accuracy purposes, the number of rows for each outputted DataFrame was cross referenced with Total Field Goal Attempts(FGA) via the official NBA stats website.
I thought it would be a good idea to display Antetokounmpo’s shots, because he has quickly gone from an unknown player in his first season, 2013-2014, to a superstar and the Most Valuable Player (MVP) of the NBA in his last complete season 2018-2019. He was the favorite to repeat as MVP for the 2019-2020 season.
In order to create the shot charts, I first needed to draw a court. This was done by using the python package matplotlib3, NBA basketball court dimensions, and following Savvas Tjortjoglou’s basketball court tutorial4. The tutorial established dimensions of the court by creating a scatter plot of all the shots using the x and y data. From there the center of the hoop was determined to be the origin (0,0) and about 10 units of the (x,y) data represented 1 foot of shot distance. For example, a shot taken from the left side of the court with a shot distance of 2 feet with a ‘x’ location of -15 would be considered to be taken from about 1.5 feet to the left of the hoop.
After the court was created, I used matplotlib to plot all shots using the x,y locations from each year’s Pandas dataframe. The completed images were exported to PNG5 image format.
For the charts, the green circles represent made shots and the tan circles represent missed shots. These colors were chosen because they are the primary colors of Giannis’s team, the Milwaukee Bucks. The fill colors were removed so the overlapping circles would be easier to see.
From the shot charts, you can clearly tell the growth Giannis has had since he entered the league in 2013-2014. The sheer volume of shots is totally different from his first season(13-14) to his most current season (19-20). There are clear differences in the number of outside shots taken in his first 3 seasons (13-15) compared to his past 3 nba seasons (16-19). As he has gotten older, he has become more comfortable with shooting from the 3 point arc. This can be seen starting from the 17-18 shot chart.
His MVP Year(18-19) shotchart shows his maturity as a scorer, as he was able to score consistently from all over the court. Even though the 19-20 season ended prematurely, Giannis was on pace to attempt and make more shots than he had in all previous seasons. The hoop is barely visible in these charts, because his favorite shot has always been a layup or dunk near the basket.
Author: Ryan Han. Last edited: 2020-05-08.
Python. Copyright (C) 2001–2020. Python Software Foundation. Accessed 2019-05-03. Online: https://www.python.org/↩︎
Pandas Python Package Version 1.0.3 Released 2020-03-18. Accessed 2020-05-07. Online: https://pandas.pydata.org/↩︎
J. D. Hunter, “Matplotlib: A 2D Graphics Environment”, Computing in Science & Engineering, vol. 9, no. 3, pp. 90-95, 2007. Accessed 2020-05-07↩︎
Savvas Tjortjoglous’s Python tutorial to create basketball court. Accessed 2020-05-03 Online: http://savvastjortjoglou.com/nba-shot-sharts.html↩︎
Portable Network Graphics (PNG). Copyright 1995–2019 Greg Roelofs. Accessed 2020-05-08. Online: http://www.libpng.org/pub/png/↩︎