I'm trying to set up the legends of each points in the scatter plot. My main problem is that the colors of each point do not match the color of what is in the legend. What am I doing wrong and how do I rectify it?
def scatter(self, indep, dep, labl):
x = self.df_input[indep]
y = self.df_input[dep]
random = np.random.RandomState(0)
colors = random.rand(len(labl)+1)
fig = plt.figure()
ax = fig.add_subplot(111)
for leg in labl:
ax.scatter(x, y, c=colors, cmap='gist_ncar', label=leg)
ax.legend()
ax.set_xlabel(indep)
ax.set_ylabel(dep)
ax.axis('tight')
plt.show()