Skip to content

Commit fc5a1da

Browse files
TST: Verify plot order of a Series (GH38865) (#39491)
1 parent 2bcd313 commit fc5a1da

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/plotting/test_series.py

+19
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,25 @@ def test_plot_no_numeric_data(self):
752752
with pytest.raises(TypeError, match="no numeric data to plot"):
753753
df.plot()
754754

755+
@pytest.mark.parametrize(
756+
"data, index",
757+
[
758+
([1, 2, 3, 4], [3, 2, 1, 0]),
759+
([10, 50, 20, 30], [1910, 1920, 1980, 1950]),
760+
],
761+
)
762+
def test_plot_order(self, data, index):
763+
# GH38865 Verify plot order of a Series
764+
ser = Series(data=data, index=index)
765+
ax = ser.plot(kind="bar")
766+
767+
expected = ser.tolist()
768+
result = [
769+
patch.get_bbox().ymax
770+
for patch in sorted(ax.patches, key=lambda patch: patch.get_bbox().xmax)
771+
]
772+
assert expected == result
773+
755774
def test_style_single_ok(self):
756775
s = Series([1, 2])
757776
ax = s.plot(style="s", color="C3")

0 commit comments

Comments
 (0)