From 9844d26b5f6964939aa59f132835919e31368b93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Wed, 9 Feb 2022 09:30:24 -0500 Subject: [PATCH] TST: Test change axis in boxplot #2980 --- pandas/tests/plotting/test_boxplot_method.py | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pandas/tests/plotting/test_boxplot_method.py b/pandas/tests/plotting/test_boxplot_method.py index d2a7d0fdb0cc2..0094c4a502bad 100644 --- a/pandas/tests/plotting/test_boxplot_method.py +++ b/pandas/tests/plotting/test_boxplot_method.py @@ -29,6 +29,27 @@ @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): + def test_stacked_boxplot_set_axis(self): + # GH2980 + import matplotlib.pyplot as plt + + n = 80 + df = DataFrame( + { + "Clinical": np.random.choice([0, 1, 2, 3], n), + "Confirmed": np.random.choice([0, 1, 2, 3], n), + "Discarded": np.random.choice([0, 1, 2, 3], n), + }, + index=np.arange(0, n), + ) + ax = df.plot(kind="bar", stacked=True) + assert [int(x.get_text()) for x in ax.get_xticklabels()] == df.index.to_list() + ax.set_xticks(np.arange(0, 80, 10)) + plt.draw() # Update changes + assert [int(x.get_text()) for x in ax.get_xticklabels()] == list( + np.arange(0, 80, 10) + ) + def test_boxplot_legacy1(self): df = DataFrame( np.random.randn(6, 4),