@@ -129,6 +129,23 @@ def test_plot_fails_when_ax_differs_from_figure(self):
129
129
with pytest .raises (AssertionError ):
130
130
self .ts .hist (ax = ax1 , figure = fig2 )
131
131
132
+ @pytest .mark .parametrize (
133
+ "histtype, expected, agg_func" ,
134
+ [
135
+ ("bar" , True , all ),
136
+ ("barstacked" , True , all ),
137
+ ("step" , False , any ),
138
+ ("stepfilled" , True , all ),
139
+ ],
140
+ )
141
+ def test_histtype_argument (self , histtype , expected , agg_func ):
142
+ # GH23992 Verify functioning of histtype argument
143
+ ser = Series (np .random .randint (1 , 10 ))
144
+ ax = ser .hist (bins = 12 , histtype = histtype )
145
+
146
+ result = agg_func (patch .fill for patch in ax .patches )
147
+ assert result == expected
148
+
132
149
@pytest .mark .parametrize (
133
150
"by, expected_axes_num, expected_layout" , [(None , 1 , (1 , 1 )), ("b" , 2 , (1 , 2 ))]
134
151
)
@@ -365,6 +382,23 @@ def test_hist_column_order_unchanged(self, column, expected):
365
382
366
383
assert result == expected
367
384
385
+ @pytest .mark .parametrize (
386
+ "histtype, expected, agg_func" ,
387
+ [
388
+ ("bar" , True , all ),
389
+ ("barstacked" , True , all ),
390
+ ("step" , False , any ),
391
+ ("stepfilled" , True , all ),
392
+ ],
393
+ )
394
+ def test_histtype_argument (self , histtype , expected , agg_func ):
395
+ # GH23992 Verify functioning of histtype argument
396
+ df = DataFrame (np .random .randint (1 , 10 , size = (100 , 2 )), columns = ["a" , "b" ])
397
+ ax = df .hist (bins = 12 , histtype = histtype , layout = (- 1 , 1 ))
398
+
399
+ result = agg_func (patch .fill for row in ax for patch in row [0 ].patches )
400
+ assert result == expected
401
+
368
402
@pytest .mark .parametrize ("by" , [None , "c" ])
369
403
@pytest .mark .parametrize ("column" , [None , "b" ])
370
404
def test_hist_with_legend (self , by , column ):
@@ -595,3 +629,22 @@ def test_axis_share_xy(self):
595
629
596
630
assert ax1 ._shared_y_axes .joined (ax1 , ax2 )
597
631
assert ax2 ._shared_y_axes .joined (ax1 , ax2 )
632
+
633
+ @pytest .mark .parametrize (
634
+ "histtype, expected, agg_func" ,
635
+ [
636
+ ("bar" , True , all ),
637
+ ("barstacked" , True , all ),
638
+ ("step" , False , any ),
639
+ ("stepfilled" , True , all ),
640
+ ],
641
+ )
642
+ def test_histtype_argument (self , histtype , expected , agg_func ):
643
+ # GH23992 Verify functioning of histtype argument
644
+ df = DataFrame (
645
+ np .random .randint (1 , 10 , size = (100 , 2 )), columns = ["a" , "b" ]
646
+ ).groupby ("a" )
647
+ ax = df .hist (bins = 12 , histtype = histtype , layout = (- 1 , 1 ))
648
+
649
+ result = agg_func (patch .fill for rows in ax for patch in rows [0 ][0 ].patches )
650
+ assert result == expected
0 commit comments