Skip to content

Commit 4f6410c

Browse files
TST: GH39126 Test barh plot with string and integer at the same column (#47306)
* TST: barh plot with string and integer at the same column (#39126) * Update pandas/tests/plotting/test_misc.py Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 9bb25b9 commit 4f6410c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/plotting/test_misc.py

+15
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,21 @@ def test_bar_plot(self):
461461
for a, b in zip(plot_bar.get_xticklabels(), expected)
462462
)
463463

464+
def test_barh_plot_labels_mixed_integer_string(self):
465+
# GH39126
466+
# Test barh plot with string and integer at the same column
467+
from matplotlib.text import Text
468+
469+
df = DataFrame([{"word": 1, "value": 0}, {"word": "knowledg", "value": 2}])
470+
plot_barh = df.plot.barh(x="word", legend=None)
471+
expected_yticklabels = [Text(0, 0, "1"), Text(0, 1, "knowledg")]
472+
assert all(
473+
actual.get_text() == expected.get_text()
474+
for actual, expected in zip(
475+
plot_barh.get_yticklabels(), expected_yticklabels
476+
)
477+
)
478+
464479
def test_has_externally_shared_axis_x_axis(self):
465480
# GH33819
466481
# Test _has_externally_shared_axis() works for x-axis

0 commit comments

Comments
 (0)