99from artist import Artist
1010from axis import XAxis , YAxis
1111from cbook import iterable , is_string_like , flatten , enumerate , True , False ,\
12- allequal , dict_delall , strip_math
12+ allequal , dict_delall , strip_math , popd
1313from collections import RegularPolyCollection , PolyCollection
1414from colors import colorConverter , normalize , Colormap , LinearSegmentedColormap
1515import cm
@@ -1474,13 +1474,13 @@ def legend(self, *args, **kwargs):
14741474 if len (args )== 0 :
14751475 labels = [line .get_label () for line in self .lines ]
14761476 lines = self .lines
1477- loc = kwargs . gry ( 'loc' , 1 )
1477+ loc = popd ( kwargs , 'loc' , 1 )
14781478
14791479 elif len (args )== 1 :
14801480 # LABELS
14811481 labels = args [0 ]
14821482 lines = [line for line , label in zip (self .lines , labels )]
1483- loc = kwargs . get ( 'loc' , 1 )
1483+ loc = popd ( kwargs , 'loc' , 1 )
14841484
14851485 elif len (args )== 2 :
14861486 if is_string_like (args [1 ]) or isinstance (args [1 ], int ):
@@ -1490,14 +1490,15 @@ def legend(self, *args, **kwargs):
14901490 else :
14911491 # LINES, LABELS
14921492 lines , labels = args
1493- loc = kwargs . get ( 'loc' , 1 )
1493+ loc = popd ( kwargs , 'loc' , 1 )
14941494
14951495 elif len (args )== 3 :
14961496 # LINES, LABELS, LOC
14971497 lines , labels , loc = args
14981498 else :
14991499 raise RuntimeError ('Invalid arguments to legend' )
15001500
1501+
15011502 lines = flatten (lines )
15021503 self .legend_ = Legend (self , lines , labels , loc , ** kwargs )
15031504 return self .legend_
0 commit comments