@@ -483,45 +483,31 @@ def __init__(self, parent, handles, labels,
483
483
if edgecolor == 'inherit' :
484
484
edgecolor = mpl .rcParams ["axes.edgecolor" ]
485
485
486
- self .legendPatch = FancyBboxPatch (
487
- xy = (0.0 , 0.0 ), width = 1. , height = 1. ,
488
- facecolor = facecolor ,
489
- edgecolor = edgecolor ,
490
- mutation_scale = self ._fontsize ,
491
- snap = True
492
- )
493
-
494
- # The width and height of the legendPatch will be set (in the
495
- # draw()) to the length that includes the padding. Thus we set
496
- # pad=0 here.
497
486
if fancybox is None :
498
487
fancybox = mpl .rcParams ["legend.fancybox" ]
499
488
500
- if fancybox :
501
- self .legendPatch .set_boxstyle ("round" , pad = 0 ,
502
- rounding_size = 0.2 )
503
- else :
504
- self .legendPatch .set_boxstyle ("square" , pad = 0 )
505
-
489
+ self .legendPatch = FancyBboxPatch (
490
+ xy = (0 , 0 ), width = 1 , height = 1 ,
491
+ facecolor = facecolor , edgecolor = edgecolor ,
492
+ # If shadow is used, default to alpha=1 (#8943).
493
+ alpha = (framealpha if framealpha is not None
494
+ else 1 if shadow
495
+ else mpl .rcParams ["legend.framealpha" ]),
496
+ # The width and height of the legendPatch will be set (in draw())
497
+ # to the length that includes the padding. Thus we set pad=0 here.
498
+ boxstyle = ("round,pad=0,rounding_size=0.2" if fancybox
499
+ else "square,pad=0" ),
500
+ mutation_scale = self ._fontsize ,
501
+ snap = True ,
502
+ )
506
503
self ._set_artist_props (self .legendPatch )
507
504
508
- self ._drawFrame = frameon
509
- if frameon is None :
510
- self ._drawFrame = mpl .rcParams ["legend.frameon" ]
505
+ self ._drawFrame = (frameon if frameon is not None
506
+ else mpl .rcParams ["legend.frameon" ])
511
507
512
508
# init with null renderer
513
509
self ._init_legend_box (handles , labels , markerfirst )
514
510
515
- # If shadow is activated use framealpha if not
516
- # explicitly passed. See Issue 8943
517
- if framealpha is None :
518
- if shadow :
519
- self .get_frame ().set_alpha (1 )
520
- else :
521
- self .get_frame ().set_alpha (mpl .rcParams ["legend.framealpha" ])
522
- else :
523
- self .get_frame ().set_alpha (framealpha )
524
-
525
511
tmp = self ._loc_used_default
526
512
self ._set_loc (loc )
527
513
self ._loc_used_default = tmp # ignore changes done by _set_loc
0 commit comments