@@ -313,46 +313,40 @@ def _auto_legend_data(self):
313313 if not self .isaxes :
314314 raise Exception , 'Auto legends not available for figure legends.'
315315
316- def get_handles (ax ):
317- handles = ax .lines [:]
318- handles .extend (ax .patches )
319- handles .extend ([c for c in ax .collections if isinstance (c , LineCollection )])
320-
321- return handles
322-
323316 ax = self .parent
324- handles = get_handles (ax )
325317 vertices = []
326318 bboxes = []
327319 lines = []
328320
329321 inv = ax .transAxes .inverse_xy_tup
330- for handle in handles :
331322
332- if isinstance (handle , Line2D ):
323+ for handle in ax .lines :
324+ assert isinstance (handle , Line2D )
333325
334- xdata = handle .get_xdata (orig = False )
335- ydata = handle .get_ydata (orig = False )
336- trans = handle .get_transform ()
337- xt , yt = trans .numerix_x_y (xdata , ydata )
326+ xdata = handle .get_xdata (orig = False )
327+ ydata = handle .get_ydata (orig = False )
328+ trans = handle .get_transform ()
329+ xt , yt = trans .numerix_x_y (xdata , ydata )
338330
339- # XXX need a special method in transform to do a list of verts
340- averts = [inv (v ) for v in zip (xt , yt )]
341- lines .append (averts )
331+ # XXX need a special method in transform to do a list of verts
332+ averts = [inv (v ) for v in zip (xt , yt )]
333+ lines .append (averts )
342334
343- elif isinstance (handle , Patch ):
335+ for handle in ax .patches :
336+ assert isinstance (handle , Patch )
344337
345- verts = handle .get_verts ()
346- trans = handle .get_transform ()
347- tverts = trans .seq_xy_tups (verts )
338+ verts = handle .get_verts ()
339+ trans = handle .get_transform ()
340+ tverts = trans .seq_xy_tups (verts )
348341
349- averts = [inv (v ) for v in tverts ]
342+ averts = [inv (v ) for v in tverts ]
350343
351- bbox = unit_bbox ()
352- bbox .update (averts , True )
353- bboxes .append (bbox )
344+ bbox = unit_bbox ()
345+ bbox .update (averts , True )
346+ bboxes .append (bbox )
354347
355- elif isinstance (handle , LineCollection ):
348+ for handle in ax .collections :
349+ if isinstance (handle , LineCollection ):
356350 hlines = handle .get_lines ()
357351 trans = handle .get_transform ()
358352 for line in hlines :
0 commit comments