diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 9cd13b2312ea7..b4848f80e9a2c 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -752,6 +752,25 @@ def test_plot_no_numeric_data(self): with pytest.raises(TypeError, match="no numeric data to plot"): df.plot() + @pytest.mark.parametrize( + "data, index", + [ + ([1, 2, 3, 4], [3, 2, 1, 0]), + ([10, 50, 20, 30], [1910, 1920, 1980, 1950]), + ], + ) + def test_plot_order(self, data, index): + # GH38865 Verify plot order of a Series + ser = Series(data=data, index=index) + ax = ser.plot(kind="bar") + + expected = ser.tolist() + result = [ + patch.get_bbox().ymax + for patch in sorted(ax.patches, key=lambda patch: patch.get_bbox().xmax) + ] + assert expected == result + def test_style_single_ok(self): s = Series([1, 2]) ax = s.plot(style="s", color="C3")