<div dir="ltr">All of the scatterplot legend examples that I can find on the web use multiple calls to plt.scatter to then obtain a legend for each color, e.g. here:<div><br></div><div><a href="http://matplotlib.org/examples/lines_bars_and_markers/scatter_with_legend.html#lines-bars-and-markers-scatter-with-legend">http://matplotlib.org/examples/lines_bars_and_markers/scatter_with_legend.html#lines-bars-and-markers-scatter-with-legend</a><br></div><div><br></div><div>However, I'm trying to make a single call to scatter, using a ListedColorMap with three colors and passing c=(array of 0, 1, or 2) to the plt.scatter call. Unfortunately, when I try to add a legend to this I get a single point/value.</div><div><br></div><div>I tried to follow the proxy patch instructions here:</div><div><a href="http://matplotlib.org/users/legend_guide.html#plotting-guide-legend">http://matplotlib.org/users/legend_guide.html#plotting-guide-legend</a><br></div><div><br></div><div>but couldn't get a circle when using patches.Circle() as the proxy object: I still get a rectangular fill patch as in the examples above.</div><div><br></div><div>For completeness, two alternative examples:</div><div><br></div><div>========================</div><div><br></div><div>import numpy as np</div><div>from matplotib import pyplot as plt, patches, color</div><div><br></div><div>x = np.random.rand(50)</div><div>y = np.random.rand(50)</div><div>color = np.random.randint(3, size=50)</div><div><br></div><div>colormap = colors.ListedColormap([(1, 0, 0),<br></div><div><div>                                    (0, 0, 1),</div><div>                                    (0, 1, 0)])</div></div><div><br></div><div>pointtypes = np.array(['type 0', 'type 1', 'type 2'])</div><div><br></div><div>plt.figure()</div><div>plt.scatter(x, y, c=color, cmap=colormap)</div><div>plt.legend(pointtypes)</div><div><br></div><div><br></div><div>plt.figure()</div><div>plt.scatter(x, y, c=color, cmap=colormap)</div><div>proxy_artists = [patches.Circle((0, 1), color=colormap(i), label=pointtypes[i]</div><div>                         for i in range(3)]</div><div>plt.legend(proxy_artists, pointtypes)</div><div><br></div><div>========================<br></div><div><br></div><div>Can anyone suggest a simple modification to obtain the above plot with the right legend?</div><div><br></div><div>Thanks!</div><div><br></div><div>Juan.</div></div>