diff --git a/doc/source/v0.14.1.txt b/doc/source/v0.14.1.txt index c41bc13b18606..8beaeb8378f82 100644 --- a/doc/source/v0.14.1.txt +++ b/doc/source/v0.14.1.txt @@ -143,7 +143,7 @@ Performance - +- Bug in subplots displays ``ticklabels`` and ``labels`` in different rule (:issue:`5897`) diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index c96fd08233238..7e44885f11c2c 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -822,6 +822,12 @@ def test_plot(self): axes = _check_plot_works(df.plot, subplots=True, title='blah') self._check_axes_shape(axes, axes_num=3, layout=(3, 1)) + for ax in axes[:2]: + self._check_visible(ax.get_xticklabels(), visible=False) + self._check_visible([ax.xaxis.get_label()], visible=False) + for ax in [axes[2]]: + self._check_visible(ax.get_xticklabels()) + self._check_visible([ax.xaxis.get_label()]) _check_plot_works(df.plot, title='blah') @@ -2331,8 +2337,16 @@ def test_grouped_box_layout(self): column='height', return_type='dict') self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(2, 2)) - box = df.boxplot(column=['height', 'weight', 'category'], by='gender') + # GH 5897 + axes = df.boxplot(column=['height', 'weight', 'category'], by='gender', + return_type='axes') self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(2, 2)) + for ax in [axes['height']]: + self._check_visible(ax.get_xticklabels(), visible=False) + self._check_visible([ax.xaxis.get_label()], visible=False) + for ax in [axes['weight'], axes['category']]: + self._check_visible(ax.get_xticklabels()) + self._check_visible([ax.xaxis.get_label()]) box = df.groupby('classroom').boxplot( column=['height', 'weight', 'category'], return_type='dict') diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index 37a982acc0bbd..c21f243a9a716 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -3022,15 +3022,16 @@ def on_right(i): if nplots > 1: if sharex and nrows > 1: - for i, ax in enumerate(axarr): - if np.ceil(float(i + 1) / ncols) < nrows: # only last row - [label.set_visible( - False) for label in ax.get_xticklabels()] + for ax in axarr[:naxes][:-ncols]: # only bottom row + for label in ax.get_xticklabels(): + label.set_visible(False) + ax.xaxis.get_label().set_visible(False) if sharey and ncols > 1: for i, ax in enumerate(axarr): if (i % ncols) != 0: # only first column - [label.set_visible( - False) for label in ax.get_yticklabels()] + for label in ax.get_yticklabels(): + label.set_visible(False) + ax.yaxis.get_label().set_visible(False) if naxes != nplots: for ax in axarr[naxes:]: