diff --git a/pandas/tests/plotting/common.py b/pandas/tests/plotting/common.py index 69120160699c2..64e1bdadffc21 100644 --- a/pandas/tests/plotting/common.py +++ b/pandas/tests/plotting/common.py @@ -4,6 +4,7 @@ from __future__ import annotations +import copy from typing import TYPE_CHECKING import numpy as np @@ -554,7 +555,8 @@ def _gen_two_subplots(f, fig, **kwargs): """ if "ax" not in kwargs: fig.add_subplot(211) - yield f(**kwargs) + # Copy iterators for 2nd call, see test_errorbar_plot_iterator + yield f(**copy.deepcopy(kwargs)) if f is pd.plotting.bootstrap_plot: assert "ax" not in kwargs diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 45dc612148f40..c8cb5435d09dc 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -103,11 +103,10 @@ def test_plot_subplots_use_index(self): _check_ticks_props(axes, xrot=0) _check_axes_shape(axes, axes_num=4, layout=(4, 1)) - @pytest.mark.xfail(reason="Api changed in 3.6.0") @pytest.mark.slow def test_plot_invalid_arg(self): df = DataFrame({"x": [1, 2], "y": [3, 4]}) - msg = "'Line2D' object has no property 'blarg'" + msg = re.escape("Line2D.set() got an unexpected keyword argument 'blarg'") with pytest.raises(AttributeError, match=msg): df.plot.line(blarg=True) @@ -659,11 +658,11 @@ def test_area_lim(self, stacked): lines = ax.get_lines() assert xmin <= lines[0].get_data()[0][0] assert xmax >= lines[0].get_data()[0][-1] - assert ymin == 0 + assert ymin == 0, ymin ax = _check_plot_works(neg_df.plot.area, stacked=stacked) ymin, ymax = ax.get_ylim() - assert ymax == 0 + assert ymax == 0, ymax def test_area_sharey_dont_overwrite(self): # GH37942 @@ -1796,7 +1795,6 @@ def test_errorbar_plot_different_yerr_xerr_subplots(self, kind): ) _check_has_errorbars(axes, xerr=1, yerr=1) - @pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError) def test_errorbar_plot_iterator(self): d = {"x": np.arange(12), "y": np.arange(12, 0, -1)} df = DataFrame(d) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 112172656b6ec..c6dab44634b89 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -293,7 +293,6 @@ def test_plot_multiple_inferred_freq(self): ser = Series(np.random.default_rng(2).standard_normal(len(dr)), index=dr) _check_plot_works(ser.plot) - @pytest.mark.xfail(reason="Api changed in 3.6.0") def test_uhf(self): import pandas.plotting._matplotlib.converter as conv @@ -309,7 +308,7 @@ def test_uhf(self): tlocs = axis.get_ticklocs() tlabels = axis.get_ticklabels() for loc, label in zip(tlocs, tlabels): - xp = conv._from_ordinal(loc).strftime("%H:%M:%S.%f") + xp = conv._from_ordinal(loc).strftime("%H:%M:%S") rs = str(label.get_text()) if len(rs): assert xp == rs @@ -1428,7 +1427,6 @@ def test_secondary_legend_nonts_multi_col(self): # TODO: color cycle problems assert len(colors) == 4 - @pytest.mark.xfail(reason="Api changed in 3.6.0") def test_format_date_axis(self): rng = date_range("1/1/2012", periods=12, freq="ME") df = DataFrame(np.random.default_rng(2).standard_normal((len(rng), 3)), rng) @@ -1437,7 +1435,7 @@ def test_format_date_axis(self): xaxis = ax.get_xaxis() for line in xaxis.get_ticklabels(): if len(line.get_text()) > 0: - assert line.get_rotation() == 30 + assert line.get_rotation() == 0.0 def test_ax_plot(self): x = date_range(start="2012-01-02", periods=10, freq="D") @@ -1652,19 +1650,16 @@ def test_overlapping_datetime(self): s2.plot(ax=ax) s1.plot(ax=ax) - @pytest.mark.xfail(reason="GH9053 matplotlib does not use ax.xaxis.converter") def test_add_matplotlib_datetime64(self): # GH9053 - ensure that a plot with PeriodConverter still understands - # datetime64 data. This still fails because matplotlib overrides the - # ax.xaxis.converter with a DatetimeConverter + # datetime64 data. s = Series( np.random.default_rng(2).standard_normal(10), index=date_range("1970-01-02", periods=10), ) ax = s.plot() - with tm.assert_produces_warning(DeprecationWarning): - # multi-dimensional indexing - ax.plot(s.index, s.values, color="g") + # multi-dimensional indexing + ax.plot(s.index, s.values, color="g") l1, l2 = ax.lines tm.assert_numpy_array_equal(l1.get_xydata(), l2.get_xydata()) diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 2b2f2f3b84307..6066c2da58210 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -863,11 +863,6 @@ def test_custom_business_day_freq(self): _check_plot_works(s.plot) - @pytest.mark.xfail( - reason="GH#24426, see also " - "github.com/pandas-dev/pandas/commit/" - "ef1bd69fa42bbed5d09dd17f08c44fc8bfc2b685#r61470674" - ) def test_plot_accessor_updates_on_inplace(self): ser = Series([1, 2, 3, 4]) _, ax = mpl.pyplot.subplots() @@ -875,7 +870,6 @@ def test_plot_accessor_updates_on_inplace(self): before = ax.xaxis.get_ticklocs() ser.drop([0, 1], inplace=True) - _, ax = mpl.pyplot.subplots() after = ax.xaxis.get_ticklocs() tm.assert_numpy_array_equal(before, after)