I have a data, which can be used in scatter plot.
I also have labels for the same data. So I am using conditional coloring:
# import needed things
fig = plt.figure()
r = fig.add_subplot(121)
r.scatter(np.arange(500), X[ :500, 0] c = Y[:500]
# x and y labels set here
g = fig.add_subplot(122)
g.scatter(np.arange(500), X[ :500, 1] c = Y[:500]
# x and y labels set here
plt.show()
I need to have a legend as well, suggesting which type has which color. I tried this:
plt.legend((r, g), ("one", "zero"), scatterpoints = 1, loc = "upper left")
but I get a warning
.../site-packages/matplotlib/legend.py:633: UserWarning: Legend does not support <matplotlib.axes._subplots.AxesSubplot object at 0x7fe37f460668> instances.
A proxy artist may be used instead.
and legend is not displayed.