Recently, I created a NBA shot chart in Power BI as part of my entry to the Microsoft Power BI Best report contest and I had got a lot of questions on how I made the visual. So I decided to write a quick post on how I made the shot chart as well as use this opportunity to present my entry, which got selected as one of the Top 10 finalists in the contest.
My interactive contest entry is embedded in this post (thanks to the new Publish to Web feature in Power BI) and a full screen version of the same report can be obtained from here.
My entry is an analysis of the first 35 games played by Stephen Curry from the Golden State Warriors in NBA. The main feature of the entry is a Shot chart which shows the position from which he attempted his shots and the color denotes whether he made or missed it.
To make a similar shot chart, follow the steps below:-
1) The most important part of any report is getting the data. I had a few sources for my data (www.nbastats.com, www.nbasavant.com, www.datavizdoneright.com) from where I directly got my (X,Y) position data. But if you are really serious, you might want to look at the following blog posts which show how to scrape data directly –
2) Once you get your (X,Y) location data, you can import the results into Power BI and then create a scatter chart from the data.
3) Get a background image for the basketball court (I used one that I found from www.datavizdoneright.com since it had the logo of Golden State Warriors and looked nice). Now you can import the image and place it behind the scatter chart. Make sure that you send the image to the back, as you need the scatter chart on top so that you can interact with the dots by clicking.
4) Now the hard part is resizing the scatter chart to the size of the court. I turned off the X and Y axis, and then turned on the X,Y reference lines so that I know where the center needs to be.
5) Once you have found the right fit, you can turn off the reference lines also and then add the shot result to differentiate between made and missed attempt. You can also add a chiclet slicer with the opponent images to see the shots by teams as shown below.
That said, there is already a custom visual called the Enhanced Scatter Plot which allows you to put an image behind a scatter plot chart. I couldn’t make my data line up with the image, and hence I had to do it the hard way. You might find it easier to use the Enhanced scatter plot directly. Hope you liked my version of the shot chart!