diff --git a/pandas/tests/plotting/frame/test_frame_color.py b/pandas/tests/plotting/frame/test_frame_color.py index e384861d8a57c..2e860c2615322 100644 --- a/pandas/tests/plotting/frame/test_frame_color.py +++ b/pandas/tests/plotting/frame/test_frame_color.py @@ -199,12 +199,18 @@ def test_if_scatterplot_colorbars_are_next_to_parent_axes(self): @pytest.mark.parametrize("kw", ["c", "color"]) def test_scatter_with_c_column_name_with_colors(self, cmap, kw): # https://github.com/pandas-dev/pandas/issues/34316 + from pandas.plotting._matplotlib.compat import mpl_ge_3_6_0 + df = DataFrame( [[5.1, 3.5], [4.9, 3.0], [7.0, 3.2], [6.4, 3.2], [5.9, 3.0]], columns=["length", "width"], ) df["species"] = ["r", "r", "g", "g", "b"] - ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) + if mpl_ge_3_6_0() and cmap is not None: + with tm.assert_produces_warning(UserWarning, check_stacklevel=False): + ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) + else: + ax = df.plot.scatter(x=0, y=1, cmap=cmap, **{kw: "species"}) assert ax.collections[0].colorbar is None def test_scatter_colors(self):