I’m making a legend for a scatter plot using a proxy artists (http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist) and attempting to make circle-shaped markers.
This is my code:
legend([Circle((0,0), fc='g')], ["Green Circle"])
But when I plot it, the legend doesn’t have a circle and instead displays a rectangle…
How do I get the legend to have circle markers?
If all you are looking for is a circular marker in the legend (as opposed to strictly using proxy artists), then I suggest trying something like:
This shows you circles of different color and sizes, where the 2D line that is drawn is white (hence
color="white"). If you don’t want the circles filled in, for example, setmarkeredgecolor="green"andmarkerfacecolor="white".Further tweaks
color="white"will still show the line.linewidth=0will completely hide the line.handletextpadkeyword argument forplt.legendto reduce the space between the circle and the label. The value can also be negative, e.g.handletextpad=-0.3.seabornpalettes, you can set the individual marker face colors by indexing the palette. E.g.markerfacecolor=sns.color_palette("cubehelix", 3)[0]