From 4665aee3445cf24b21d62f0eb982d85e2c46d6ac Mon Sep 17 00:00:00 2001 From: Dmitry Savostyanov Date: Sat, 11 Jun 2022 01:00:08 +0300 Subject: [PATCH 1/2] TST: barh plot with string and integer at the same column (#39126) --- pandas/tests/plotting/test_misc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 9c7996adfed38..e7878f58d1dce 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -461,6 +461,21 @@ def test_bar_plot(self): for a, b in zip(plot_bar.get_xticklabels(), expected) ) + def test_barh_plot(self): + # GH39126 + # Test barh plot with string and integer at the same column + from matplotlib.text import Text + + df = DataFrame([{"word": 1, "value": 0}, {"word": "knowledg", "value": 2}]) + plot_barh = df.plot.barh(x="word", legend=None) + expected_yticklabels = [Text(0, 0, "1"), Text(0, 1, "knowledg")] + assert all( + actual.get_text() == expected.get_text() + for actual, expected in zip( + plot_barh.get_yticklabels(), expected_yticklabels + ) + ) + def test_has_externally_shared_axis_x_axis(self): # GH33819 # Test _has_externally_shared_axis() works for x-axis From 998ba1ff76f7c3f66cede70610a721f33742e910 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Fri, 10 Jun 2022 16:43:21 -0700 Subject: [PATCH 2/2] Update pandas/tests/plotting/test_misc.py --- pandas/tests/plotting/test_misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index e7878f58d1dce..ca82c37b8a8b0 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -461,7 +461,7 @@ def test_bar_plot(self): for a, b in zip(plot_bar.get_xticklabels(), expected) ) - def test_barh_plot(self): + def test_barh_plot_labels_mixed_integer_string(self): # GH39126 # Test barh plot with string and integer at the same column from matplotlib.text import Text