On Wed, Sep 5, 2012 at 6:05 AM, Sterling Smith <smit...@fusion.gat.com> wrote:
> I still do not get black markers.  Furthermore, if you try to make a new 
> legend with the result of leg.get_lines(), you will get lines without 
> markers, which leads me to the conclusion I stated in my previous email 
> (which you did not copy)
>>> I suspect that this is because the legend marker is drawn separately from 
>>> the legend line to accommodate the numpoints argument of the legend 
>>> functions.  Then the question is how to access these markers if they are 
>>> separate from the line2d objects in the legend.  I didn't even see them in 
>>> the children of the legend [legend.get_children()].

This is correct. To support legend handle like --o-- (i.e., no markers
at the ends), lines and markers are drawn as a separate artist. You
may use something like,

line[0]._legmarker.set_markerfacecolor('black')
line[1]._legmarker.set_markerfacecolor('black')

I, personally, recommend you to use a proxy artist.

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

For example,

You may do something like

import pylab
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='')
pylab.plot(pylab.linspace(0,1,100),marker='o',ls='-')

# creates artists for legend purpose only
l1, = pylab.plot(pylab.linspace(0,1,100), 'ko-')
l2, = pylab.plot(pylab.linspace(0,1,100), 'ko')
# remove them from the axes.
l1.remove()
l2.remove()

leg=pylab.legend([l1, l2], ["Test 1", "Test 2"], loc='best')

Regards,

-JJ

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to