First Question so apologies if I mess this up!!
I have csv data like this 3 columns with headers and 10 rows:
player | pass_att | pass_cmp |
---|---|---|
Dak Prescott | 58 | 42 |
Tom Brady | 50 | 32 |
Jalen Hurts | 35 | 27 |
Matt Ryan | 35 | 21 |
Ben Roethlisberger | 32 | 18 |
Josh Allen | 51 | 30 |
Zach Wilson | 37 | 20 |
Sam Darnold | 35 | 24 |
Kirk Cousins | 49 | 36 |
Joe Burrow | 27 | 20 |
I am reading in the data and producing a graph with the pass attempts as the x-axis and the pass completions as the y-axis and I am trying to use the 'player' column as lables for where my x and y data points intersect. I have tried using the annotate() function and the text() function but I cannot seem to pass the 'player' column in so it will read the values as text labels.
nfl_df = pd.read_csv('nfl2.csv')
nfl_df = nfl_df.sort_values(by ='pass_att', ascending = False)
np_arr = nfl_df.values
x_2 = np_arr[:, 2]
y_2 = np_arr[:, 1]
#z_2 = nfl_df.column('player')
fig_4 = plt.figure(figsize = (6,4))
axes_4 = fig_4.add_axes([2,2,3,3])
axes_4.set_xlabel('Pass Att')
axes_4.set_ylabel('Pass Cmp')
axes_4.set_title('Pass Att vs Pass Cmp')
axes_4.plot(x_2,y_2,z_2)
axes_4.plot(x_2,y_2, color='cyan', alpha = .90, lw = 2, ls = '-.', marker = 'o', markersize = 7, markerfacecolor = 'b')
#plt.annotate(z_2,(x_2,y_2))
Any help here would be appreciated and thanks for the help