Skip to content

Commit 1136a04

Browse files
NumberPiOsoyehoshuadimarsky
authored andcommitted
TST: Test change axis in boxplot pandas-dev#2980 (pandas-dev#45899)
1 parent b2bf207 commit 1136a04

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/plotting/test_boxplot_method.py

+21
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@
2929

3030
@td.skip_if_no_mpl
3131
class TestDataFramePlots(TestPlotBase):
32+
def test_stacked_boxplot_set_axis(self):
33+
# GH2980
34+
import matplotlib.pyplot as plt
35+
36+
n = 80
37+
df = DataFrame(
38+
{
39+
"Clinical": np.random.choice([0, 1, 2, 3], n),
40+
"Confirmed": np.random.choice([0, 1, 2, 3], n),
41+
"Discarded": np.random.choice([0, 1, 2, 3], n),
42+
},
43+
index=np.arange(0, n),
44+
)
45+
ax = df.plot(kind="bar", stacked=True)
46+
assert [int(x.get_text()) for x in ax.get_xticklabels()] == df.index.to_list()
47+
ax.set_xticks(np.arange(0, 80, 10))
48+
plt.draw() # Update changes
49+
assert [int(x.get_text()) for x in ax.get_xticklabels()] == list(
50+
np.arange(0, 80, 10)
51+
)
52+
3253
def test_boxplot_legacy1(self):
3354
df = DataFrame(
3455
np.random.randn(6, 4),

0 commit comments

Comments
 (0)