Skip to content

Commit e5b4e6f

Browse files
committed
Add test for bar and line plot superposition with same x values
This test ensures that bar and line plots with identical x values are correctly superposed on the same axes. It verifies that the x-tick positions remain consistent across plot types.
1 parent ee183d7 commit e5b4e6f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/plotting/test_series.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,3 +971,17 @@ def test_secondary_y_subplot_axis_labels(self):
971971
s1.plot(ax=ax2)
972972
assert len(ax.xaxis.get_minor_ticks()) == 0
973973
assert len(ax.get_xticklabels()) > 0
974+
975+
def test_bar_line_plot(self):
976+
"""
977+
Test that bar and line plots with the same x values are superposed
978+
"""
979+
# GH61161
980+
index = period_range("2023", periods=3, freq="Y")
981+
s = Series([1, 2, 3], index=index)
982+
ax = plt.subplot()
983+
s.plot(kind="bar", ax=ax)
984+
bar_xticks = ax.get_xticks().tolist()
985+
s.plot(kind="line", ax=ax, color="r")
986+
line_xticks = ax.get_xticks()[: len(s)].tolist()
987+
assert line_xticks == bar_xticks

0 commit comments

Comments
 (0)