@@ -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 )
29442944def test_scatter_c (self ,c_case ,re_key ):
2945- def get_next_color ():
2945+ def get_next_color ():# pragma: no cover
29462946return 'blue' # currently unused
29472947
29482948xsize = 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
30403040return 'blue' # currently unused
30413041
30423042c ,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
30673067return 'blue' # currently unused
30683068
30693069c = 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
30793079return 'blue' # currently unused
30803080
30813081with pytest .raises (ValueError ,
@@ -3085,6 +3085,55 @@ def get_next_color():
30853085c ,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
30903139class Polar :
@@ -9064,8 +9113,8 @@ def test_child_axes_removal():
90649113
90659114def test_scatter_color_repr_error ():
90669115
9067- def get_next_color ():
9068- return 'blue' #pragma: no cover
9116+ def get_next_color ():# pragma: no cover
9117+ return 'blue' #currently unused
90699118msg = (
90709119r"'c' argument must be a color, a sequence of colors"
90719120r", or a sequence of numbers, not 'red\\n'"