On Tue, Jun 24, 2008 at 1:57 AM, Stéfan van der Walt <[EMAIL PROTECTED]> wrote: > Hi all, > > Sorry to bump the thread, but has anyone had a chance to take a look? > > I've re-attached the patch.
Thanks for the reminder and sorry for the delay getting back. The problem in the patch was that the "self.texts" variable and "self.legendHandles" variables are assumed to be equal length lists. When you added an extra marker line but not an extra label, the layout got out of whack, but this was masked in "_update_positions" by a silent zip failure. I replaced that call with our cbook.safezip function, which will at least fail noisily if the input lists are unequal (note to all mpl devels, use safezip rather than zip). The solution was not to modify the legendHandles return list "ret" at all, since tracking that through all the hairy legend code proved untenable. Instead, I made the code a little hairier by tacking on your marker proxy as an attribute of the legend line:: legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)]) legline_marker.update_from(handle) legline_marker.set_linestyle('None') self._set_artist_props(legline_marker) # we don't want to add this to the return list because # the texts and handles are assumed to be in one to ne # correpondence. legline._legmarker = legline_marker and then accessing the "_legmarker" attr in _update_positions and draw. Note you can use the marker 'None' rather than setting the markersize to 0; we use the string 'None' for the marker and linestyle since None means "do the rc default" in many contexts. Committed to svn r5654 -- here is the test script:: import numpy as np import matplotlib.pyplot as plt plt.plot(np.random.rand(10), 'x-', label='first line') plt.plot(np.random.rand(10), 'o-.', label='second line') plt.legend(numpoints=1) plt.show() At some point we need to do a clean room impl of the legend code as it is suffering from feature creep and the internals are getting uglier. JDH ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel