From f79e77e5b2cec7bb14af2ce830ccffa018ad5887 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:21:21 -0700 Subject: [PATCH] TST: Clean tests/plotting/test_frame.py misc --- .../tests/plotting/frame/test_frame_legend.py | 48 ++- .../plotting/frame/test_frame_subplots.py | 301 ++++++++++-------- 2 files changed, 200 insertions(+), 149 deletions(-) diff --git a/pandas/tests/plotting/frame/test_frame_legend.py b/pandas/tests/plotting/frame/test_frame_legend.py index 5914300b00434..13c31a6a202d7 100644 --- a/pandas/tests/plotting/frame/test_frame_legend.py +++ b/pandas/tests/plotting/frame/test_frame_legend.py @@ -26,7 +26,6 @@ class TestFrameLegend: ) def test_mixed_yerr(self): # https://github.com/pandas-dev/pandas/issues/39522 - import matplotlib as mpl from matplotlib.collections import LineCollection from matplotlib.lines import Line2D @@ -46,8 +45,6 @@ def test_mixed_yerr(self): def test_legend_false(self): # https://github.com/pandas-dev/pandas/issues/40044 - import matplotlib as mpl - df = DataFrame({"a": [1, 1], "b": [2, 3]}) df2 = DataFrame({"d": [2.5, 2.5]}) @@ -63,27 +60,31 @@ def test_legend_false(self): assert result == expected @td.skip_if_no_scipy - def test_df_legend_labels(self): - kinds = ["line", "bar", "barh", "kde", "area", "hist"] + @pytest.mark.parametrize("kind", ["line", "bar", "barh", "kde", "area", "hist"]) + def test_df_legend_labels(self, kind): df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) df2 = DataFrame(np.random.rand(3, 3), columns=["d", "e", "f"]) df3 = DataFrame(np.random.rand(3, 3), columns=["g", "h", "i"]) df4 = DataFrame(np.random.rand(3, 3), columns=["j", "k", "l"]) - for kind in kinds: - ax = df.plot(kind=kind, legend=True) - _check_legend_labels(ax, labels=df.columns) + ax = df.plot(kind=kind, legend=True) + _check_legend_labels(ax, labels=df.columns) - ax = df2.plot(kind=kind, legend=False, ax=ax) - _check_legend_labels(ax, labels=df.columns) + ax = df2.plot(kind=kind, legend=False, ax=ax) + _check_legend_labels(ax, labels=df.columns) - ax = df3.plot(kind=kind, legend=True, ax=ax) - _check_legend_labels(ax, labels=df.columns.union(df3.columns)) + ax = df3.plot(kind=kind, legend=True, ax=ax) + _check_legend_labels(ax, labels=df.columns.union(df3.columns)) - ax = df4.plot(kind=kind, legend="reverse", ax=ax) - expected = list(df.columns.union(df3.columns)) + list(reversed(df4.columns)) - _check_legend_labels(ax, labels=expected) + ax = df4.plot(kind=kind, legend="reverse", ax=ax) + expected = list(df.columns.union(df3.columns)) + list(reversed(df4.columns)) + _check_legend_labels(ax, labels=expected) + @td.skip_if_no_scipy + def test_df_legend_labels_secondary_y(self): + df = DataFrame(np.random.rand(3, 3), columns=["a", "b", "c"]) + df2 = DataFrame(np.random.rand(3, 3), columns=["d", "e", "f"]) + df3 = DataFrame(np.random.rand(3, 3), columns=["g", "h", "i"]) # Secondary Y ax = df.plot(legend=True, secondary_y="b") _check_legend_labels(ax, labels=["a", "b (right)", "c"]) @@ -92,6 +93,8 @@ def test_df_legend_labels(self): ax = df3.plot(kind="bar", legend=True, secondary_y="h", ax=ax) _check_legend_labels(ax, labels=["a", "b (right)", "c", "g", "h (right)", "i"]) + @td.skip_if_no_scipy + def test_df_legend_labels_time_series(self): # Time Series ind = date_range("1/1/2014", periods=3) df = DataFrame(np.random.randn(3, 3), columns=["a", "b", "c"], index=ind) @@ -104,6 +107,13 @@ def test_df_legend_labels(self): ax = df3.plot(legend=True, ax=ax) _check_legend_labels(ax, labels=["a", "b (right)", "c", "g", "h", "i"]) + @td.skip_if_no_scipy + def test_df_legend_labels_time_series_scatter(self): + # Time Series + ind = date_range("1/1/2014", periods=3) + df = DataFrame(np.random.randn(3, 3), columns=["a", "b", "c"], index=ind) + df2 = DataFrame(np.random.randn(3, 3), columns=["d", "e", "f"], index=ind) + df3 = DataFrame(np.random.randn(3, 3), columns=["g", "h", "i"], index=ind) # scatter ax = df.plot.scatter(x="a", y="b", label="data1") _check_legend_labels(ax, labels=["data1"]) @@ -112,6 +122,10 @@ def test_df_legend_labels(self): ax = df3.plot.scatter(x="g", y="h", label="data3", ax=ax) _check_legend_labels(ax, labels=["data1", "data3"]) + @td.skip_if_no_scipy + def test_df_legend_labels_time_series_no_mutate(self): + ind = date_range("1/1/2014", periods=3) + df = DataFrame(np.random.randn(3, 3), columns=["a", "b", "c"], index=ind) # ensure label args pass through and # index name does not mutate # column names don't mutate @@ -128,7 +142,7 @@ def test_df_legend_labels(self): def test_missing_marker_multi_plots_on_same_ax(self): # GH 18222 df = DataFrame(data=[[1, 1, 1, 1], [2, 2, 4, 8]], columns=["x", "r", "g", "b"]) - fig, ax = mpl.pyplot.subplots(nrows=1, ncols=3) + _, ax = mpl.pyplot.subplots(nrows=1, ncols=3) # Left plot df.plot(x="x", y="r", linewidth=0, marker="o", color="r", ax=ax[0]) df.plot(x="x", y="g", linewidth=1, marker="x", color="g", ax=ax[0]) @@ -210,7 +224,7 @@ def test_missing_markers_legend_using_style(self): } ) - fig, ax = mpl.pyplot.subplots() + _, ax = mpl.pyplot.subplots() for kind in "ABC": df.plot("X", kind, label=kind, ax=ax, style=".") diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index fd21a42298bdb..2534d8b99515b 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -28,81 +28,97 @@ from pandas.io.formats.printing import pprint_thing mpl = pytest.importorskip("matplotlib") +plt = pytest.importorskip("matplotlib.pyplot") class TestDataFramePlotsSubplots: @pytest.mark.slow - def test_subplots(self): + @pytest.mark.parametrize("kind", ["bar", "barh", "line", "area"]) + def test_subplots(self, kind): df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) - for kind in ["bar", "barh", "line", "area"]: - axes = df.plot(kind=kind, subplots=True, sharex=True, legend=True) - _check_axes_shape(axes, axes_num=3, layout=(3, 1)) - assert axes.shape == (3,) - - for ax, column in zip(axes, df.columns): - _check_legend_labels(ax, labels=[pprint_thing(column)]) - - for ax in axes[:-2]: - _check_visible(ax.xaxis) # xaxis must be visible for grid - _check_visible(ax.get_xticklabels(), visible=False) - if kind != "bar": - # change https://github.com/pandas-dev/pandas/issues/26714 - _check_visible(ax.get_xticklabels(minor=True), visible=False) - _check_visible(ax.xaxis.get_label(), visible=False) - _check_visible(ax.get_yticklabels()) - - _check_visible(axes[-1].xaxis) - _check_visible(axes[-1].get_xticklabels()) - _check_visible(axes[-1].get_xticklabels(minor=True)) - _check_visible(axes[-1].xaxis.get_label()) - _check_visible(axes[-1].get_yticklabels()) - - axes = df.plot(kind=kind, subplots=True, sharex=False) - for ax in axes: - _check_visible(ax.xaxis) - _check_visible(ax.get_xticklabels()) - _check_visible(ax.get_xticklabels(minor=True)) - _check_visible(ax.xaxis.get_label()) - _check_visible(ax.get_yticklabels()) - - axes = df.plot(kind=kind, subplots=True, legend=False) - for ax in axes: - assert ax.get_legend() is None - - def test_subplots_timeseries(self): + axes = df.plot(kind=kind, subplots=True, sharex=True, legend=True) + _check_axes_shape(axes, axes_num=3, layout=(3, 1)) + assert axes.shape == (3,) + + for ax, column in zip(axes, df.columns): + _check_legend_labels(ax, labels=[pprint_thing(column)]) + + for ax in axes[:-2]: + _check_visible(ax.xaxis) # xaxis must be visible for grid + _check_visible(ax.get_xticklabels(), visible=False) + if kind != "bar": + # change https://github.com/pandas-dev/pandas/issues/26714 + _check_visible(ax.get_xticklabels(minor=True), visible=False) + _check_visible(ax.xaxis.get_label(), visible=False) + _check_visible(ax.get_yticklabels()) + + _check_visible(axes[-1].xaxis) + _check_visible(axes[-1].get_xticklabels()) + _check_visible(axes[-1].get_xticklabels(minor=True)) + _check_visible(axes[-1].xaxis.get_label()) + _check_visible(axes[-1].get_yticklabels()) + + @pytest.mark.slow + @pytest.mark.parametrize("kind", ["bar", "barh", "line", "area"]) + def test_subplots_no_share_x(self, kind): + df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) + axes = df.plot(kind=kind, subplots=True, sharex=False) + for ax in axes: + _check_visible(ax.xaxis) + _check_visible(ax.get_xticklabels()) + _check_visible(ax.get_xticklabels(minor=True)) + _check_visible(ax.xaxis.get_label()) + _check_visible(ax.get_yticklabels()) + + @pytest.mark.slow + @pytest.mark.parametrize("kind", ["bar", "barh", "line", "area"]) + def test_subplots_no_legend(self, kind): + df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) + axes = df.plot(kind=kind, subplots=True, legend=False) + for ax in axes: + assert ax.get_legend() is None + + @pytest.mark.parametrize("kind", ["line", "area"]) + def test_subplots_timeseries(self, kind): idx = date_range(start="2014-07-01", freq="M", periods=10) df = DataFrame(np.random.rand(10, 3), index=idx) - for kind in ["line", "area"]: - axes = df.plot(kind=kind, subplots=True, sharex=True) - _check_axes_shape(axes, axes_num=3, layout=(3, 1)) + axes = df.plot(kind=kind, subplots=True, sharex=True) + _check_axes_shape(axes, axes_num=3, layout=(3, 1)) - for ax in axes[:-2]: - # GH 7801 - _check_visible(ax.xaxis) # xaxis must be visible for grid - _check_visible(ax.get_xticklabels(), visible=False) - _check_visible(ax.get_xticklabels(minor=True), visible=False) - _check_visible(ax.xaxis.get_label(), visible=False) - _check_visible(ax.get_yticklabels()) - - _check_visible(axes[-1].xaxis) - _check_visible(axes[-1].get_xticklabels()) - _check_visible(axes[-1].get_xticklabels(minor=True)) - _check_visible(axes[-1].xaxis.get_label()) - _check_visible(axes[-1].get_yticklabels()) - _check_ticks_props(axes, xrot=0) - - axes = df.plot(kind=kind, subplots=True, sharex=False, rot=45, fontsize=7) - for ax in axes: - _check_visible(ax.xaxis) - _check_visible(ax.get_xticklabels()) - _check_visible(ax.get_xticklabels(minor=True)) - _check_visible(ax.xaxis.get_label()) - _check_visible(ax.get_yticklabels()) - _check_ticks_props(ax, xlabelsize=7, xrot=45, ylabelsize=7) - - def test_subplots_timeseries_y_axis(self): + for ax in axes[:-2]: + # GH 7801 + _check_visible(ax.xaxis) # xaxis must be visible for grid + _check_visible(ax.get_xticklabels(), visible=False) + _check_visible(ax.get_xticklabels(minor=True), visible=False) + _check_visible(ax.xaxis.get_label(), visible=False) + _check_visible(ax.get_yticklabels()) + + _check_visible(axes[-1].xaxis) + _check_visible(axes[-1].get_xticklabels()) + _check_visible(axes[-1].get_xticklabels(minor=True)) + _check_visible(axes[-1].xaxis.get_label()) + _check_visible(axes[-1].get_yticklabels()) + _check_ticks_props(axes, xrot=0) + + @pytest.mark.parametrize("kind", ["line", "area"]) + def test_subplots_timeseries_rot(self, kind): + idx = date_range(start="2014-07-01", freq="M", periods=10) + df = DataFrame(np.random.rand(10, 3), index=idx) + axes = df.plot(kind=kind, subplots=True, sharex=False, rot=45, fontsize=7) + for ax in axes: + _check_visible(ax.xaxis) + _check_visible(ax.get_xticklabels()) + _check_visible(ax.get_xticklabels(minor=True)) + _check_visible(ax.xaxis.get_label()) + _check_visible(ax.get_yticklabels()) + _check_ticks_props(ax, xlabelsize=7, xrot=45, ylabelsize=7) + + @pytest.mark.parametrize( + "col", ["numeric", "timedelta", "datetime_no_tz", "datetime_all_tz"] + ) + def test_subplots_timeseries_y_axis(self, col): # GH16953 data = { "numeric": np.array([1, 2, 5]), @@ -125,13 +141,18 @@ def test_subplots_timeseries_y_axis(self): } testdata = DataFrame(data) - y_cols = ["numeric", "timedelta", "datetime_no_tz", "datetime_all_tz"] - for col in y_cols: - ax = testdata.plot(y=col) - result = ax.get_lines()[0].get_data()[1] - expected = testdata[col].values - assert (result == expected).all() + ax = testdata.plot(y=col) + result = ax.get_lines()[0].get_data()[1] + expected = testdata[col].values + assert (result == expected).all() + def test_subplots_timeseries_y_text_error(self): + # GH16953 + data = { + "numeric": np.array([1, 2, 5]), + "text": ["This", "should", "fail"], + } + testdata = DataFrame(data) msg = "no numeric data to plot" with pytest.raises(TypeError, match=msg): testdata.plot(y="text") @@ -187,34 +208,28 @@ def test_subplots_timeseries_y_axis_not_supported(self): == testdata["datetime_mixed_tz"].values ).all() - def test_subplots_layout_multi_column(self): + @pytest.mark.parametrize( + "layout, exp_layout", + [ + [(2, 2), (2, 2)], + [(-1, 2), (2, 2)], + [(2, -1), (2, 2)], + [(1, 4), (1, 4)], + [(-1, 4), (1, 4)], + [(4, -1), (4, 1)], + ], + ) + def test_subplots_layout_multi_column(self, layout, exp_layout): # GH 6667 df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) - axes = df.plot(subplots=True, layout=(2, 2)) - _check_axes_shape(axes, axes_num=3, layout=(2, 2)) - assert axes.shape == (2, 2) - - axes = df.plot(subplots=True, layout=(-1, 2)) - _check_axes_shape(axes, axes_num=3, layout=(2, 2)) - assert axes.shape == (2, 2) - - axes = df.plot(subplots=True, layout=(2, -1)) - _check_axes_shape(axes, axes_num=3, layout=(2, 2)) - assert axes.shape == (2, 2) - - axes = df.plot(subplots=True, layout=(1, 4)) - _check_axes_shape(axes, axes_num=3, layout=(1, 4)) - assert axes.shape == (1, 4) - - axes = df.plot(subplots=True, layout=(-1, 4)) - _check_axes_shape(axes, axes_num=3, layout=(1, 4)) - assert axes.shape == (1, 4) - - axes = df.plot(subplots=True, layout=(4, -1)) - _check_axes_shape(axes, axes_num=3, layout=(4, 1)) - assert axes.shape == (4, 1) + axes = df.plot(subplots=True, layout=layout) + _check_axes_shape(axes, axes_num=3, layout=exp_layout) + assert axes.shape == exp_layout + def test_subplots_layout_multi_column_error(self): + # GH 6667 + df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) msg = "Layout of 1x1 must be larger than required size 3" with pytest.raises(ValueError, match=msg): @@ -269,42 +284,45 @@ def test_subplots_multiple_axes(self): _check_axes_shape(axes, axes_num=6, layout=(2, 3)) tm.close() + def test_subplots_multiple_axes_error(self): + # GH 5353, 6970, GH 7069 + df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) msg = "The number of passed axes must be 3, the same as the output plot" + _, axes = mpl.pyplot.subplots(2, 3) with pytest.raises(ValueError, match=msg): - fig, axes = mpl.pyplot.subplots(2, 3) # pass different number of axes from required df.plot(subplots=True, ax=axes) + @pytest.mark.parametrize( + "layout, exp_layout", + [ + [(2, 1), (2, 2)], + [(2, -1), (2, 2)], + [(-1, 2), (2, 2)], + ], + ) + def test_subplots_multiple_axes_2_dim(self, layout, exp_layout): + # GH 5353, 6970, GH 7069 # pass 2-dim axes and invalid layout # invalid lauout should not affect to input and return value # (show warning is tested in # TestDataFrameGroupByPlots.test_grouped_box_multiple_axes - fig, axes = mpl.pyplot.subplots(2, 2) + _, axes = mpl.pyplot.subplots(2, 2) + df = DataFrame(np.random.rand(10, 4), index=list(string.ascii_letters[:10])) with warnings.catch_warnings(): warnings.simplefilter("ignore", UserWarning) - df = DataFrame(np.random.rand(10, 4), index=list(string.ascii_letters[:10])) - - returned = df.plot( - subplots=True, ax=axes, layout=(2, 1), sharex=False, sharey=False - ) - _check_axes_shape(returned, axes_num=4, layout=(2, 2)) - assert returned.shape == (4,) returned = df.plot( - subplots=True, ax=axes, layout=(2, -1), sharex=False, sharey=False + subplots=True, ax=axes, layout=layout, sharex=False, sharey=False ) - _check_axes_shape(returned, axes_num=4, layout=(2, 2)) + _check_axes_shape(returned, axes_num=4, layout=exp_layout) assert returned.shape == (4,) - returned = df.plot( - subplots=True, ax=axes, layout=(-1, 2), sharex=False, sharey=False - ) - _check_axes_shape(returned, axes_num=4, layout=(2, 2)) - assert returned.shape == (4,) - + def test_subplots_multiple_axes_single_col(self): + # GH 5353, 6970, GH 7069 # single column - fig, axes = mpl.pyplot.subplots(1, 1) + _, axes = mpl.pyplot.subplots(1, 1) df = DataFrame(np.random.rand(10, 1), index=list(string.ascii_letters[:10])) axes = df.plot(subplots=True, ax=[axes], sharex=False, sharey=False) @@ -313,7 +331,7 @@ def test_subplots_multiple_axes(self): def test_subplots_ts_share_axes(self): # GH 3964 - fig, axes = mpl.pyplot.subplots(3, 3, sharex=True, sharey=True) + _, axes = mpl.pyplot.subplots(3, 3, sharex=True, sharey=True) mpl.pyplot.subplots_adjust(left=0.05, right=0.95, hspace=0.3, wspace=0.3) df = DataFrame( np.random.randn(10, 9), @@ -360,15 +378,19 @@ def test_subplots_dup_columns(self): for ax in axes: _check_legend_labels(ax, labels=["a"]) assert len(ax.lines) == 1 - tm.close() + def test_subplots_dup_columns_secondary_y(self): + # GH 10962 + df = DataFrame(np.random.rand(5, 5), columns=list("aaaaa")) axes = df.plot(subplots=True, secondary_y="a") for ax in axes: # (right) is only attached when subplots=False _check_legend_labels(ax, labels=["a"]) assert len(ax.lines) == 1 - tm.close() + def test_subplots_dup_columns_secondary_y_no_subplot(self): + # GH 10962 + df = DataFrame(np.random.rand(5, 5), columns=list("aaaaa")) ax = df.plot(secondary_y="a") _check_legend_labels(ax, labels=["a (right)"] * 5) assert len(ax.lines) == 0 @@ -427,8 +449,6 @@ def test_boxplot_subplots_return_type(self, hist_df, rt): def test_df_subplots_patterns_minorticks(self): # GH 10657 - import matplotlib.pyplot as plt - df = DataFrame( np.random.randn(10, 2), index=date_range("1/1/2000", periods=10), @@ -436,7 +456,7 @@ def test_df_subplots_patterns_minorticks(self): ) # shared subplots - fig, axes = plt.subplots(2, 1, sharex=True) + _, axes = plt.subplots(2, 1, sharex=True) axes = df.plot(subplots=True, ax=axes) for ax in axes: assert len(ax.lines) == 1 @@ -446,9 +466,15 @@ def test_df_subplots_patterns_minorticks(self): _check_visible(axes[0].get_xticklabels(minor=True), visible=False) _check_visible(axes[1].get_xticklabels(), visible=True) _check_visible(axes[1].get_xticklabels(minor=True), visible=True) - tm.close() - fig, axes = plt.subplots(2, 1) + def test_df_subplots_patterns_minorticks_1st_ax_hidden(self): + # GH 10657 + df = DataFrame( + np.random.randn(10, 2), + index=date_range("1/1/2000", periods=10), + columns=list("AB"), + ) + _, axes = plt.subplots(2, 1) with tm.assert_produces_warning(UserWarning): axes = df.plot(subplots=True, ax=axes, sharex=True) for ax in axes: @@ -459,17 +485,22 @@ def test_df_subplots_patterns_minorticks(self): _check_visible(axes[0].get_xticklabels(minor=True), visible=False) _check_visible(axes[1].get_xticklabels(), visible=True) _check_visible(axes[1].get_xticklabels(minor=True), visible=True) - tm.close() + def test_df_subplots_patterns_minorticks_not_shared(self): + # GH 10657 + df = DataFrame( + np.random.randn(10, 2), + index=date_range("1/1/2000", periods=10), + columns=list("AB"), + ) # not shared - fig, axes = plt.subplots(2, 1) + _, axes = plt.subplots(2, 1) axes = df.plot(subplots=True, ax=axes) for ax in axes: assert len(ax.lines) == 1 _check_visible(ax.get_yticklabels(), visible=True) _check_visible(ax.get_xticklabels(), visible=True) _check_visible(ax.get_xticklabels(minor=True), visible=True) - tm.close() def test_subplots_sharex_false(self): # test when sharex is set to False, two plots should have different @@ -478,7 +509,7 @@ def test_subplots_sharex_false(self): df.iloc[5:, 1] = np.nan df.iloc[:5, 0] = np.nan - figs, axs = mpl.pyplot.subplots(2, 1) + _, axs = mpl.pyplot.subplots(2, 1) df.plot.line(ax=axs, subplots=True, sharex=False) expected_ax1 = np.arange(4.5, 10, 0.5) @@ -494,7 +525,7 @@ def test_subplots_constrained_layout(self): kwargs = {} if hasattr(mpl.pyplot.Figure, "get_constrained_layout"): kwargs["constrained_layout"] = True - fig, axes = mpl.pyplot.subplots(2, **kwargs) + _, axes = mpl.pyplot.subplots(2, **kwargs) with tm.assert_produces_warning(None): df.plot(ax=axes[0]) with tm.ensure_clean(return_filelike=True) as path: @@ -608,14 +639,20 @@ def test_bar_barwidth_position_int(self, w): assert ax.patches[0].get_x() == -0.5 assert ax.patches[-1].get_x() == 3.5 - def test_bar_barwidth_position_int_width_1(self): + @pytest.mark.parametrize( + "kind, kwargs", + [ + ["bar", {"stacked": True}], + ["barh", {"stacked": False}], + ["barh", {"stacked": True}], + ["bar", {"subplots": True}], + ["barh", {"subplots": True}], + ], + ) + def test_bar_barwidth_position_int_width_1(self, kind, kwargs): # GH 12979 df = DataFrame(np.random.randn(5, 5)) - self._check_bar_alignment(df, kind="bar", stacked=True, width=1) - self._check_bar_alignment(df, kind="barh", stacked=False, width=1) - self._check_bar_alignment(df, kind="barh", stacked=True, width=1) - self._check_bar_alignment(df, kind="bar", subplots=True, width=1) - self._check_bar_alignment(df, kind="barh", subplots=True, width=1) + self._check_bar_alignment(df, kind=kind, width=1, **kwargs) def _check_bar_alignment( self,