@@ -683,6 +683,13 @@ def test_bar_plt_xaxis_intervalrange(self):
683
683
)
684
684
685
685
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
+
686
693
@pytest .fixture
687
694
def df_bar_data ():
688
695
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
816
823
_df_bar_subplot_checker (
817
824
df_bar_data , df_bar_df , subplot_data_df_list [i ], subplot_division [i ]
818
825
)
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