Skip to content

Commit 9dd73d1

Browse files
committed
Updated Test cases
1 parent e55d907 commit 9dd73d1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/tests/plotting/test_misc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,13 @@ def test_bar_plt_xaxis_intervalrange(self):
683683
)
684684

685685

686+
def test_plot_bar_label_count_default():
687+
df = DataFrame(
688+
[(30, 10, 10, 10), (20, 20, 20, 20), (10, 30, 30, 10)], columns=list("ABCD")
689+
)
690+
df.plot(subplots=True, kind="bar", title=["A", "B", "C", "D"])
691+
692+
686693
@pytest.fixture
687694
def df_bar_data():
688695
return np.random.default_rng(3).integers(0, 100, 5)
@@ -816,3 +823,24 @@ def test_bar_2_subplots_1_triple_stacked(df_bar_data, df_bar_df, subplot_divisio
816823
_df_bar_subplot_checker(
817824
df_bar_data, df_bar_df, subplot_data_df_list[i], subplot_division[i]
818825
)
826+
def test_plot_bar_label_count_expected_fail():
827+
df = DataFrame(
828+
[(30, 10, 10, 10), (20, 20, 20, 20), (10, 30, 30, 10)], columns=list("ABCD")
829+
)
830+
with pytest.raises(
831+
ValueError,
832+
match="The length of `title` must equal the number of columns "
833+
"if using `title` of type `list` and `subplots=True`.",
834+
):
835+
df.plot(
836+
subplots=[("A", "B")],
837+
kind="bar",
838+
title=["A&B", "C", "D", "Extra Title"],
839+
)
840+
841+
842+
def test_plot_bar_label_count_expected_success():
843+
df = DataFrame(
844+
[(30, 10, 10, 10), (20, 20, 20, 20), (10, 30, 30, 10)], columns=list("ABCD")
845+
)
846+
df.plot(subplots=[("A", "B", "D")], kind="bar", title=["A&B&D", "C"])

0 commit comments

Comments
 (0)