@@ -484,13 +484,11 @@ def __init__(self, parent, handles, labels,
484
484
raise TypeError ("Legend needs either Axes or Figure as parent" )
485
485
self .parent = parent
486
486
487
+ self ._loc_used_default = loc is None
487
488
if loc is None :
488
- self ._loc_used_default = True
489
489
loc = rcParams ["legend.loc" ]
490
490
if not self .isaxes and loc in [0 , 'best' ]:
491
491
loc = 'upper right'
492
- else :
493
- self ._loc_used_default = False
494
492
if isinstance (loc , str ):
495
493
if loc not in self .codes :
496
494
if self .isaxes :
@@ -571,7 +569,9 @@ def __init__(self, parent, handles, labels,
571
569
else :
572
570
self .get_frame ().set_alpha (framealpha )
573
571
574
- self ._set_loc (loc , is_initial_setting = True )
572
+ tmp = self ._loc_used_default
573
+ self ._set_loc (loc )
574
+ self ._loc_used_default = tmp # ignore changes done by _set_loc
575
575
576
576
# figure out title fontsize:
577
577
if title_fontsize is None :
@@ -592,13 +592,11 @@ def _set_artist_props(self, a):
592
592
593
593
a .set_transform (self .get_transform ())
594
594
595
- def _set_loc (self , loc , is_initial_setting = False ):
595
+ def _set_loc (self , loc ):
596
596
# find_offset function will be provided to _legend_box and
597
597
# _legend_box will draw itself at the location of the return
598
598
# value of the find_offset.
599
- if not is_initial_setting :
600
- # User manually changed self._loc
601
- self ._loc_used_default = False
599
+ self ._loc_used_default = False
602
600
self ._loc_real = loc
603
601
self .stale = True
604
602
self ._legend_box .set_offset (self ._findoffset )
0 commit comments