@@ -532,6 +532,30 @@ def test_empty_bar_chart_with_legend():
532
532
plt .legend ()
533
533
534
534
535
+ def test_shadow_argument_types ():
536
+ # Test that different arguments for shadow work as expected
537
+ fig , ax = plt .subplots ()
538
+ ax .plot ([1 , 2 , 3 ], label = 'test' )
539
+ shadows = [True , False , 'red' , (0.1 , 0.2 , 0.5 ), 'tab:cyan' , False ]
540
+
541
+ legends = (ax .legend (loc = 'upper left' , shadow = True ), # True
542
+ ax .legend (loc = 'upper right' , shadow = False ), # False
543
+ ax .legend (loc = 'center left' , shadow = 'red' ), # Color string
544
+ ax .legend (loc = 'center right' , shadow = (0.1 , 0.2 , 0.5 )), # Color tuple
545
+ ax .legend (loc = 'lower left' , shadow = 'tab:cyan' ) # Color tab
546
+ )
547
+ for l in legends :
548
+ ax .add_artist (l )
549
+ ax .legend (loc = 'lower right' ) # default
550
+
551
+ legends = [c for c in ax .get_children () if isinstance (c , mpl .legend .Legend )]
552
+ assert len (legends ) == len (shadows )
553
+ for i in range (len (legends )):
554
+ assert legends [i ].shadow == shadows [i ]
555
+
556
+ with pytest .raises (ValueError , match = "color or bool" ):
557
+ ax .legend (loc = "upper left" , shadow = "aardvark" ) # Bad argument
558
+
535
559
def test_shadow_framealpha ():
536
560
# Test if framealpha is activated when shadow is True
537
561
# and framealpha is not explicitly passed'''
0 commit comments