This Plotly chart was created using a dataset of NBA players stats from basketball-reference.com. It contains player points, rebounds, assists, starts and etc. I create this visualization by building it in Plotly, based on an initial Python plot created using Matplotlib. I wanted to explore using Plotly cause I thought it would be cool for the user to be able to hover over the data to see how players improved or declined over time.

From the data, you can see that Wilt Chamberlin had the highest points per game at 50. However, he had a very quick decline. I’m not an avid fan of basketball so I would love to know other players to look at it.

Check Out the Code

import plotly.plotly as py import plotly.graph_objs as go import pandas as pd import plotly from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot seasons=pd.read_csv('Players_Seasons_Stats.csv') plotly.tools.set_credentials_file(username='XXXX', api_key='XXXXXXXX') seasonsplt = go.Scatter( x=seasons.Year, y=seasons.ppg, name ='All', marker=dict( size=3, opacity = 0.5 ), mode='markers') seasonplt2=go.Scatter( x=seasons.Year[seasons.Player == 'Kobe Bryant'], y=seasons.ppg[seasons.Player == 'Kobe Bryant'], name='Kobe Bryant', line = dict(width = 2), ) seasonplt3=go.Scatter( x=seasons.Year[seasons.Player == 'Wilt Chamberlain*'], y=seasons.ppg[seasons.Player == 'Wilt Chamberlain*'], name='Wilt Chamberlain*', line = dict(width = 2) ) seasonplt4=go.Scatter( x=seasons.Year[seasons.Player == 'LeBron James'], y=seasons.ppg[seasons.Player == 'LeBron James'], name='LeBron James', line = dict(width = 2) ) seasonplt5=go.Scatter( x=seasons.Year[seasons.Player == 'Michael Jordan*'], y=seasons.ppg[seasons.Player == 'Michael Jordan*'], name='Michael Jordan*', line = dict(width = 2) ) seasonplt6=go.Scatter( x=seasons.Year[seasons.Player == 'Magic Johnson*'], y=seasons.ppg[seasons.Player == 'Magic Johnson*'], name='Magic Johnson*', line = dict(width = 2) ) seasonplt7=go.Scatter( x=seasons.Year[seasons.Player == 'Larry Bird*'], y=seasons.ppg[seasons.Player == 'Larry Bird*'], name='Larry Bird*', line = dict(width = 2) ) seasonplt8=go.Scatter( x=seasons.Year[seasons.Player == 'Bill Russell*'], y=seasons.ppg[seasons.Player == 'Bill Russell*'], name='Bill Russell', line = dict(width = 2) ) seasonplt9=go.Scatter( x=seasons.Year[seasons.Player == 'Kevin Durant'], y=seasons.ppg[seasons.Player == 'Kevin Durant'], name='Kevin Durant', line = dict(width = 2) ) data = [seasonsplt,seasonplt2,seasonplt3,seasonplt4,seasonplt5,seasonplt6,seasonplt7,seasonplt8,seasonplt9] layout = go.Layout( legend=dict( orientation="h", x=.1,y=1.3) ) figure=go.Figure(data=data, layout=layout) py.iplot(figure)