@@ -2942,7 +2942,7 @@ def test_scatter_different_shapes(self, fig_test, fig_ref):
29422942
29432943 @pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
29442944 def test_scatter_c (self , c_case , re_key ):
2945- def get_next_color ():
2945+ def get_next_color (): # pragma: no cover
29462946 return 'blue' # currently unused
29472947
29482948 xsize = 4
@@ -3036,7 +3036,7 @@ def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
30363036 _result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
30373037 ])
30383038def test_parse_scatter_color_args (params , expected_result ):
3039- def get_next_color ():
3039+ def get_next_color (): # pragma: no cover
30403040 return 'blue' # currently unused
30413041
30423042 c , colors , _edgecolors = mpl .axes .Axes ._parse_scatter_color_args (
@@ -3063,7 +3063,7 @@ def get_next_color():
30633063 (dict (color = 'r' , edgecolor = 'g' ), 'g' ),
30643064 ])
30653065def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
3066- def get_next_color ():
3066+ def get_next_color (): # pragma: no cover
30673067 return 'blue' # currently unused
30683068
30693069 c = kwargs .pop ('c' , None )
@@ -3075,7 +3075,7 @@ def get_next_color():
30753075
30763076
30773077def test_parse_scatter_color_args_error ():
3078- def get_next_color ():
3078+ def get_next_color (): # pragma: no cover
30793079 return 'blue' # currently unused
30803080
30813081 with pytest .raises (ValueError ,
@@ -3085,6 +3085,55 @@ def get_next_color():
30853085 c , None , kwargs = {}, xsize = 2 , get_next_color_func = get_next_color )
30863086
30873087
3088+ # Warning message tested in the next two tests.
3089+ WARN_MSG = (
3090+ "You passed both c and facecolor/facecolors for the markers. "
3091+ "c has precedence over facecolor/facecolors. This behavior may "
3092+ "change in the future."
3093+ )
3094+ # Test cases shared between direct and integration tests
3095+ COLOR_TEST_CASES = [
3096+ ('red' , 'blue' ),
3097+ (['red' , 'blue' ], ['green' , 'yellow' ]),
3098+ ([[1 , 0 , 0 ], [0 , 1 , 0 ]], [[0 , 0 , 1 ], [1 , 1 , 0 ]])
3099+ ]
3100+
3101+
3102+ @pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
3103+ def test_parse_c_facecolor_warning_direct (c , facecolor ):
3104+ """Test the internal _parse_scatter_color_args method directly."""
3105+ def get_next_color (): # pragma: no cover
3106+ return 'blue' # currently unused
3107+
3108+ # Test with facecolors (plural)
3109+ with pytest .warns (UserWarning , match = WARN_MSG ):
3110+ mpl .axes .Axes ._parse_scatter_color_args (
3111+ c = c , edgecolors = None , kwargs = {'facecolors' : facecolor },
3112+ xsize = 2 , get_next_color_func = get_next_color )
3113+
3114+ # Test with facecolor (singular)
3115+ with pytest .warns (UserWarning , match = WARN_MSG ):
3116+ mpl .axes .Axes ._parse_scatter_color_args (
3117+ c = c , edgecolors = None , kwargs = {'facecolor' : facecolor },
3118+ xsize = 2 , get_next_color_func = get_next_color )
3119+
3120+
3121+ @pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
3122+ def test_scatter_c_facecolor_warning_integration (c , facecolor ):
3123+ """Test the warning through the actual scatter plot creation."""
3124+ fig , ax = plt .subplots ()
3125+ x = [0 , 1 ] if isinstance (c , (list , tuple )) else [0 ]
3126+ y = x
3127+
3128+ # Test with facecolors (plural)
3129+ with pytest .warns (UserWarning , match = WARN_MSG ):
3130+ ax .scatter (x , y , c = c , facecolors = facecolor )
3131+
3132+ # Test with facecolor (singular)
3133+ with pytest .warns (UserWarning , match = WARN_MSG ):
3134+ ax .scatter (x , y , c = c , facecolor = facecolor )
3135+
3136+
30883137def test_as_mpl_axes_api ():
30893138 # tests the _as_mpl_axes api
30903139 class Polar :
@@ -9046,8 +9095,8 @@ def test_child_axes_removal():
90469095
90479096def test_scatter_color_repr_error ():
90489097
9049- def get_next_color ():
9050- return 'blue' # pragma: no cover
9098+ def get_next_color (): # pragma: no cover
9099+ return 'blue' # currently unused
90519100 msg = (
90529101 r"'c' argument must be a color, a sequence of colors"
90539102 r", or a sequence of numbers, not 'red\\n'"
0 commit comments