Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## matplotlib-users

 [Matplotlib-users] Markers in legend? From: Robert Leftwich - 2005-02-15 00:50:27 ```Is it possible to include a marker from one or more scatter plots in the legend? Robert ```
 Re: [Matplotlib-users] Markers in legend? From: John Hunter - 2005-02-16 14:39:08 ```>>>>> "Robert" == Robert Leftwich writes: Robert> Is it possible to include a marker from one or more Robert> scatter plots in the legend? Robert This is a bit tricky -- scatter plots can vary in size and color. What should one use for the legend marker? So the short answer is no. My question for you is, "how *should* it work?" Not if you are using homogeneous marker sizes and colors, I suggest using plot markers tweaking the properties, as in line, = plot(x,y,linestyle='None', marker='s', markerfacecolor='red', markeredgecolor='g', markersize=20, markeredgewith=3) or the pithy line, = plot(x, y, ls='None', marker='s', mfc='red', mec='g', ms=20,, mew=3) These you can add to the legend. legend((line,), ('label',)) In matplotlib-0.72, this will be as fast or faster than scatter for the agg backend. Probably faster. If this is not an option -- eg you need variation in size but not color, you can use a line as a stand-in in your legend. Create the line, don't add it to the axes, but pass it to the legend sizes = 20*rand(len(x)) scatter(x,y,s=sizes, marker='o', c='red') # now create the proxy line but don't add it to axes for drawing line = Line2D(x,y,marker='o', color='red') legend((line,), ('label',)) This is untested, so let me know how it goes... JDH ```
 Re: [Matplotlib-users] Markers in legend? From: Robert Leftwich - 2005-02-18 05:34:29 ```John Hunter wrote: > Robert> Is it possible to include a marker from one or more > Robert> scatter plots in the legend? > > This is a bit tricky -- scatter plots can vary in size and color. Well, in my newbie-ness I wasn't aware that this was the case. > What should one use for the legend marker? So the short answer is no. > My question for you is, "how *should* it work?" > > Not if you are using homogeneous marker sizes and colors, I suggest > using plot markers tweaking the properties, as in > > line, = plot(x,y,linestyle='None', marker='s', > markerfacecolor='red', markeredgecolor='g', > markersize=20, markeredgewith=3) > For me, this is exactly how it should work - thanks! Robert ```