88import matplotlib as mpl
99import matplotlib .pyplot as plt
1010import matplotlib .collections as mcollections
11+ import matplotlib .colors as mcolors
1112import matplotlib .transforms as mtransforms
1213from matplotlib .collections import (Collection , LineCollection ,
1314 EventCollection , PolyCollection )
@@ -750,10 +751,13 @@ def test_legend_inverse_size_label_relationship():
750751 assert_array_almost_equal (handle_sizes , legend_sizes , decimal = 1 )
751752
752753
754+ @pytest .mark .style ('default' )
753755@pytest .mark .parametrize ('pcfunc' , [plt .pcolor , plt .pcolormesh ])
754756def test_color_logic (pcfunc ):
757+ rgba_none = mcolors .to_rgba_array ('none' )
755758 z = np .arange (12 ).reshape (3 , 4 )
756759 pc = pcfunc (z , edgecolors = 'red' , facecolors = 'none' )
760+ face_default = mcolors .to_rgba_array (pc ._get_default_facecolor ())
757761 assert_array_equal (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
758762 # Check setting attributes after initialization:
759763 pc = pcfunc (z )
@@ -762,22 +766,25 @@ def test_color_logic(pcfunc):
762766 assert_array_equal (pc .get_edgecolor (), [[1 , 0 , 0 , 1 ]])
763767 pc .set_alpha (0.5 )
764768 assert_array_equal (pc .get_edgecolor (), [[1 , 0 , 0 , 0.5 ]])
765- pc .set_edgecolor (None )
769+ pc .set_edgecolor (None ) # reset to default
770+ pc .set_alpha (None ) # restore default alpha
766771 pc .update_scalarmappable ()
767772 assert pc .get_edgecolor ().shape == (12 , 4 ) # color-mapped
768773 pc .set_facecolor (None )
769774 pc .update_scalarmappable ()
770775 assert pc .get_facecolor ().shape == (12 , 4 ) # color-mapped
771- assert pc .get_edgecolor (). shape == ( 1 , 4 ) # no longer color-mapped
776+ assert_array_equal ( pc .get_edgecolor (), rgba_none ) # default: 'none'
772777 # Turn off colormapping entirely:
773778 pc .set_array (None )
774779 pc .update_scalarmappable ()
780+ assert_array_equal (pc .get_edgecolor (), rgba_none )
775781 assert pc .get_facecolor ().shape == (1 , 4 ) # no longer color-mapped
782+ assert_array_equal (pc .get_facecolor (), face_default )
776783 # Turn it back on by restoring the array (must be 1D!):
777784 pc .set_array (z .ravel ())
778785 pc .update_scalarmappable ()
779786 assert pc .get_facecolor ().shape == (12 , 4 ) # color-mapped
780- assert pc .get_edgecolor (). shape == ( 1 , 4 ) # not color-mapped
787+ assert_array_equal ( pc .get_edgecolor (), rgba_none )
781788 # Give color via tuple rather than string.
782789 pc = pcfunc (z , edgecolors = (1 , 0 , 0 ), facecolors = (0 , 1 , 0 ))
783790 assert_array_equal (pc .get_facecolor (), [[0 , 1 , 0 , 1 ]])
0 commit comments