@@ -2765,24 +2765,6 @@ def test_scatter_color_warning(self, kwargs):
2765
2765
plt .scatter ([], [], c = [], ** kwargs )
2766
2766
plt .scatter ([1 , 2 ], [3 , 4 ], c = [4 , 5 ], ** kwargs )
2767
2767
2768
- @pytest .mark .parametrize ('colors' ,
2769
- [
2770
- ('red' , 'blue' ),
2771
- (['red' , 'blue' ], ['green' , 'yellow' ]),
2772
- ([[1 , 0 , 0 ], [0 , 1 , 0 ]], [[0 , 0 , 1 ], [1 , 1 , 0 ]])
2773
- ])
2774
- def test_scatter_c_facecolor_warning (self , colors ):
2775
- warn_match = (
2776
- "You passed both c and facecolor/facecolors for the markers. "
2777
- "c has precedence over facecolor/facecolors. This behavior may "
2778
- "change in the future."
2779
- )
2780
- fig , ax = plt .subplots ()
2781
- x = [0 , 1 ] if len (colors [0 ]) == 2 else [0 ]
2782
- y = x
2783
- with pytest .warns (UserWarning , match = warn_match ):
2784
- ax .scatter (x , y , c = colors [0 ], facecolors = colors [1 ])
2785
-
2786
2768
def test_scatter_unfilled (self ):
2787
2769
coll = plt .scatter ([0 , 1 , 2 ], [1 , 3 , 2 ], c = ['0.1' , '0.3' , '0.5' ],
2788
2770
marker = mmarkers .MarkerStyle ('o' , fillstyle = 'none' ),
@@ -3066,6 +3048,55 @@ def get_next_color():
3066
3048
c , None , kwargs = {}, xsize = 2 , get_next_color_func = get_next_color )
3067
3049
3068
3050
3051
+ # Warning message tested in the next two tests.
3052
+ WARN_MSG = (
3053
+ "You passed both c and facecolor/facecolors for the markers. "
3054
+ "c has precedence over facecolor/facecolors. This behavior may "
3055
+ "change in the future."
3056
+ )
3057
+ # Test cases shared between direct and integration tests
3058
+ COLOR_TEST_CASES = [
3059
+ ('red' , 'blue' ),
3060
+ (['red' , 'blue' ], ['green' , 'yellow' ]),
3061
+ ([[1 , 0 , 0 ], [0 , 1 , 0 ]], [[0 , 0 , 1 ], [1 , 1 , 0 ]])
3062
+ ]
3063
+
3064
+
3065
+ @pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
3066
+ def test_parse_c_facecolor_warning_direct (c , facecolor ):
3067
+ """Test the internal _parse_scatter_color_args method directly."""
3068
+ def get_next_color ():
3069
+ return 'blue'
3070
+
3071
+ # Test with facecolors (plural)
3072
+ with pytest .warns (UserWarning , match = WARN_MSG ):
3073
+ mpl .axes .Axes ._parse_scatter_color_args (
3074
+ c = c , edgecolors = None , kwargs = {'facecolors' : facecolor },
3075
+ xsize = 2 , get_next_color_func = get_next_color )
3076
+
3077
+ # Test with facecolor (singular)
3078
+ with pytest .warns (UserWarning , match = WARN_MSG ):
3079
+ mpl .axes .Axes ._parse_scatter_color_args (
3080
+ c = c , edgecolors = None , kwargs = {'facecolor' : facecolor },
3081
+ xsize = 2 , get_next_color_func = get_next_color )
3082
+
3083
+
3084
+ @pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
3085
+ def test_scatter_c_facecolor_warning_integration (c , facecolor ):
3086
+ """Test the warning through the actual scatter plot creation."""
3087
+ fig , ax = plt .subplots ()
3088
+ x = [0 , 1 ] if isinstance (c , (list , tuple )) else [0 ]
3089
+ y = x
3090
+
3091
+ # Test with facecolors (plural)
3092
+ with pytest .warns (UserWarning , match = WARN_MSG ):
3093
+ ax .scatter (x , y , c = c , facecolors = facecolor )
3094
+
3095
+ # Test with facecolor (singular)
3096
+ with pytest .warns (UserWarning , match = WARN_MSG ):
3097
+ ax .scatter (x , y , c = c , facecolor = facecolor )
3098
+
3099
+
3069
3100
def test_as_mpl_axes_api ():
3070
3101
# tests the _as_mpl_axes api
3071
3102
class Polar :
0 commit comments