Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 913105f

Browse files
committed
Merged revisions 6818 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint ........ r6818 | jdh2358 | 2009-01-21 21:06:44 -0600 (Wed, 21 Jan 2009) | 1 line fixed line collections legmarker sf bug 2511280 ........ svn path=/trunk/matplotlib/; revision=6819
1 parent 99bc8a7 commit 913105f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/matplotlib/legend.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def __init__(self, parent, handles, labels,
272272
self._set_artist_props(self.legendPatch)
273273

274274
self._drawFrame = True
275-
275+
276276
# init with null renderer
277277
self._init_legend_box(handles, labels)
278278

@@ -327,9 +327,9 @@ def draw(self, renderer):
327327

328328
def findoffset(width, height, xdescent, ydescent):
329329
return _findoffset(width, height, xdescent, ydescent, renderer)
330-
330+
331331
self._legend_box.set_offset(findoffset)
332-
332+
333333
fontsize = renderer.points_to_pixels(self.fontsize)
334334

335335
# if mode == fill, set the width of the legend_box to the
@@ -623,8 +623,11 @@ def _update_legend_box(self, renderer):
623623
ydata = ((height-descent)/2.)*np.ones(xdata.shape, float)
624624
legline.set_data(xdata, ydata)
625625

626-
legline_marker = legline._legmarker
627-
legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
626+
# if a line collection is added, the legmarker attr is
627+
# not set so we don't need to handle it
628+
if hasattr(handle, "_legmarker"):
629+
legline_marker = legline._legmarker
630+
legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
628631

629632
elif isinstance(handle, Patch):
630633
p = handle
@@ -765,7 +768,7 @@ def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer):
765768
C:"C"}
766769

767770
c = anchor_coefs[loc]
768-
771+
769772
fontsize = renderer.points_to_pixels(self.fontsize)
770773
container = parentbbox.padded(-(self.borderaxespad) * fontsize)
771774
anchored_box = bbox.anchored(c, container=container)

0 commit comments

Comments
 (0)