I've a single scatter plot. However, I've differentiated the points using another column (Playoffs - {0, 1}).
Now how can I give the 0 values for Playoffs a label and the 1 values another label?
fig = plt.figure(figsize=(8, 6))
plt.scatter(nba.ptsDiff, nba.W, s=25, c=nba.Playoffs, label='bla')
plt.legend()
plt.show()
Try filtering the playoff value in the columns. Then plot each using a separate plt.scatter command. Finally use lists of the plots and the legend labels in legend.
fig = plt.figure(figsize=(8, 6))
nba1 = nba[nba['Playoffs'] == 1]
nba0 = nba[nba['Playoffs'] == 0]
pla = plt.scatter(nba1.ptsDiff, nba1.W, color='red')
plb = plt.scatter(nba0.ptsDiff, nba0.W, color='blue')
plt.legend([pla, plb], ["Attr A", "Attr B"])
plt.show()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments