Visualizing NBA Passing Networks With Python

Chris Humphreys – USA TODAY Sports

The NBA’s statistics website has a lot of cool data on passing. Every player’s page includes exactly how many passes they’ve completed to each player on their team, along with the number of passes they’ve received from each of their teammates. This data also includes the number of assists created through these connections between two players. For instance, Nikola Jokic has thrown 4897 passes this season. 1887 of these passes were to Jamal Murray alone. Murray has made 37.2% of his 3-pointers off of passes from Jokic, while his 3P% drops to 33.3% off of passes from any of his other teammates.

Pretty neat information. Staring at numbers gets rather boring, though, so I want to make a visualization that easily communicates the passing connections within a team. It’s not a novel idea, but I wanted to try making some on my own using the NetworkX package with Python.

The idea here is to illustrate the connectivity of a team’s offense. Here’s an example: the 2017 Golden State Warriors and 2018 Houston Rockets both boasted historically efficient offenses headlined by all-time great talents like Stephen Curry, Kevin Durant, James Harden, and Chris Paul. However, these offenses operated in very different ways, which we can observe by comparing their respective assist networks:

Each node (or circle) represents a player, and the size of each node reflects the number of assists each player has recorded. A line between two nodes means that the players have assisted one another at least once, and the opacity of each line corresponds with the number of assists between two players. Direction is not a factor in these visualizations to prevent clutter. In other words, Player A assisting Player B is counted the same as Player B assisting Player A — there are not two separate lines.

The difference between the two assist networks is pretty obvious at this point.

The 2017 Warriors’ network clearly includes four players who are connected with black lines representing a lot of passing going on between them. Of course, these four players are Stephen Curry, Kevin Durant, Klay Thompson, and Draymond Green.

Meanwhile, the 2018 Rockets only have one connection that really stands out from the rest — James Harden and Clint Capela. Outside of that, the degree of connectivity for Houston is extremely low compared to the 2017 Warriors.

Remember, this isn’t necessarily a bad thing. The Rockets were an extremely good team, largely due to their historically efficient offense. James Harden won league MVP and they managed to take the 2018 Warriors to Game 7 in the Western Conference Finals despite a hamstring injury sidelining Chris Paul. It would be narrow-minded to just look at their final result and claim that an isolation-based offense is doomed to fail. But it’s still interesting to look at these visualizations so we can actually see the difference in play style between teams.

Let’s take a look at another example. The Blazers have undergone a lot of change in the past year. Star center Jusuf Nurkic has been sidelined all year due to injury. The team traded for Hassan Whiteside to take his place, and lost players like Seth Curry, Al-Farouq Aminu, Moe Harkless, Evan Turner, and Enes Kanter. Carmelo Anthony and Trevor Ariza were picked up during the season as well to fill gaps caused by injuries to Rodney Hood and Zach Collins. So, what’s been the effect of all of this on their offense? Here are the assist networks for the 2018-19 and 2019-20 Portland Trail Blazers:

The Blazers’ offense still seems to be based around a “triangle” of connections between their star-studded backcourt of Damian Lillard and CJ McCollum along with their big man. This season, Hassan Whiteside is obviously occupying that role at center.

You can also see a pretty large node in 2019 representing Evan Turner. Turner often assumed ball-handling duties for the bench unit and therefore racked up his fair share of assists dished out to the likes of Zach Collins, Seth Curry, and Meyers Leonard. Turner is no longer with the team, but it doesn’t seem like anybody on the 2020 Blazers has actually made up for his loss in terms of assists. The nodes for Lillard and McCollum are not any bigger, after all. Turns out the Blazers’ assist percentage this season has plummeted to last in the NBA.

I think there’s a lot more analysis that can be done with this data, and these visualizations are just a fraction of it. I’ll certainly revisit this topic in the future. For now, here’s the code for creating the networks yourself using Python. I was originally planning on having this article serve as a walkthrough tutorial, but the code for creating the networks with NetworkX became more complicated than I anticipated.

Comments

  Subscribe  
Notify of