@@ -2942,7 +2942,7 @@ def test_scatter_different_shapes(self, fig_test, fig_ref):
2942
2942
2943
2943
@pytest .mark .parametrize ('c_case, re_key' ,params_test_scatter_c )
2944
2944
def test_scatter_c (self ,c_case ,re_key ):
2945
- def get_next_color ():
2945
+ def get_next_color ():# pragma: no cover
2946
2946
return 'blue' # currently unused
2947
2947
2948
2948
xsize = 4
@@ -3036,7 +3036,7 @@ def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
3036
3036
_result (c = ['b' ,'g' ],colors = np .array ([[0 ,0 ,1 ,1 ], [0 ,.5 ,0 ,1 ]]))),
3037
3037
])
3038
3038
def test_parse_scatter_color_args (params ,expected_result ):
3039
- def get_next_color ():
3039
+ def get_next_color ():# pragma: no cover
3040
3040
return 'blue' # currently unused
3041
3041
3042
3042
c ,colors ,_edgecolors = mpl .axes .Axes ._parse_scatter_color_args (
@@ -3063,7 +3063,7 @@ def get_next_color():
3063
3063
(dict (color = 'r' ,edgecolor = 'g' ),'g' ),
3064
3064
])
3065
3065
def test_parse_scatter_color_args_edgecolors (kwargs ,expected_edgecolors ):
3066
- def get_next_color ():
3066
+ def get_next_color ():# pragma: no cover
3067
3067
return 'blue' # currently unused
3068
3068
3069
3069
c = kwargs .pop ('c' ,None )
@@ -3075,7 +3075,7 @@ def get_next_color():
3075
3075
3076
3076
3077
3077
def test_parse_scatter_color_args_error ():
3078
- def get_next_color ():
3078
+ def get_next_color ():# pragma: no cover
3079
3079
return 'blue' # currently unused
3080
3080
3081
3081
with pytest .raises (ValueError ,
@@ -3085,6 +3085,55 @@ def get_next_color():
3085
3085
c ,None ,kwargs = {},xsize = 2 ,get_next_color_func = get_next_color )
3086
3086
3087
3087
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
+
3088
3137
def test_as_mpl_axes_api ():
3089
3138
# tests the _as_mpl_axes api
3090
3139
class Polar :
@@ -9064,8 +9113,8 @@ def test_child_axes_removal():
9064
9113
9065
9114
def test_scatter_color_repr_error ():
9066
9115
9067
- def get_next_color ():
9068
- return 'blue' #pragma: no cover
9116
+ def get_next_color ():# pragma: no cover
9117
+ return 'blue' #currently unused
9069
9118
msg = (
9070
9119
r"'c' argument must be a color, a sequence of colors"
9071
9120
r", or a sequence of numbers, not 'red\\n'"