Skip to content

Commit db33849

Browse files
TST: Verify functioning of histtype argument (GH23992)
1 parent 89cc5bf commit db33849

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

pandas/tests/plotting/test_hist_method.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ def test_plot_fails_when_ax_differs_from_figure(self):
129129
with pytest.raises(AssertionError):
130130
self.ts.hist(ax=ax1, figure=fig2)
131131

132+
@pytest.mark.parametrize(
133+
"histtype, expected",
134+
[("bar", True), ("barstacked", True), ("step", False), ("stepfilled", True)],
135+
)
136+
def test_histtype_argument(self, histtype, expected):
137+
# GH23992 Verify functioning of histtype argument
138+
ser = Series(np.random.randint(1, 10))
139+
ax = ser.hist(bins=12, alpha=0.5, histtype=histtype)
140+
for patch in ax.patches:
141+
assert patch.fill is expected
142+
132143
@pytest.mark.parametrize(
133144
"by, expected_axes_num, expected_layout", [(None, 1, (1, 1)), ("b", 2, (1, 2))]
134145
)
@@ -365,6 +376,18 @@ def test_hist_column_order_unchanged(self, column, expected):
365376

366377
assert result == expected
367378

379+
@pytest.mark.parametrize(
380+
"histtype, expected",
381+
[("bar", True), ("barstacked", True), ("step", False), ("stepfilled", True)],
382+
)
383+
def test_histtype_argument(self, histtype, expected):
384+
# GH23992 Verify functioning of histtype argument
385+
df = DataFrame(np.random.randint(1, 10, size=(100, 2)), columns=["a", "b"])
386+
axes = df.hist(bins=12, alpha=0.5, histtype=histtype)
387+
for ax in axes[0]:
388+
for patch in ax.patches:
389+
assert patch.fill is expected
390+
368391
@pytest.mark.parametrize("by", [None, "c"])
369392
@pytest.mark.parametrize("column", [None, "b"])
370393
def test_hist_with_legend(self, by, column):
@@ -595,3 +618,18 @@ def test_axis_share_xy(self):
595618

596619
assert ax1._shared_y_axes.joined(ax1, ax2)
597620
assert ax2._shared_y_axes.joined(ax1, ax2)
621+
622+
@pytest.mark.parametrize(
623+
"histtype, expected",
624+
[("bar", True), ("barstacked", True), ("step", False), ("stepfilled", True)],
625+
)
626+
def test_histtype_argument(self, histtype, expected):
627+
# GH23992 Verify functioning of histtype argument
628+
df = DataFrame(
629+
np.random.randint(1, 10, size=(100, 2)), columns=["a", "b"]
630+
).groupby("a")
631+
axes = df.hist(bins=12, alpha=0.5, histtype=histtype)
632+
for sub_axes in axes:
633+
for ax in sub_axes[0]:
634+
for patch in ax.patches:
635+
assert patch.fill is expected

0 commit comments

Comments
 (0)