Skip to content

Commit 326f1a2

Browse files
committed
fix: test; should plot in order and not sorted
1 parent cb22f9b commit 326f1a2

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

pandas/plotting/_matplotlib/core.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1807,13 +1807,12 @@ def orientation(self) -> PlottingOrientation:
18071807

18081808
# GH56611 checks similar to LinePlot's _is_ts_plot and _use_dynamic_x
18091809
@final
1810-
def _is_usable_series(self) -> bool:
1811-
return self._is_series and not (
1812-
self.use_index and use_dynamic_x(self._get_ax(0), self.data)
1813-
)
1810+
def _is_ts_plot(self, data) -> bool:
1811+
return self.use_index and use_dynamic_x(self._get_ax(0), data)
18141812

1813+
@final
18151814
def _set_tick_pos(self, data) -> np.ndarray:
1816-
if self._is_usable_series():
1815+
if self._is_series and not self._is_ts_plot(data):
18171816
return np.array(self._get_xticks(), dtype=int)
18181817
else:
18191818
return np.arange(len(data))

pandas/tests/plotting/test_series.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,7 @@ def test_plot_order(self, data, index):
919919
ax = ser.plot(kind="bar")
920920

921921
expected = ser.tolist()
922-
result = [
923-
patch.get_bbox().ymax
924-
for patch in sorted(ax.patches, key=lambda patch: patch.get_bbox().xmax)
925-
]
922+
result = [patch.get_bbox().ymax for patch in ax.patches]
926923
assert expected == result
927924

928925
def test_style_single_ok(self):

0 commit comments

Comments
 (0)