Repository: pandas-dev/pandas

Issue:
'rot' parameter to DataFrame.boxplot not applied to some axes when multi-panel plot is produced using 'by'
Minimal snippet:

``` python
import pandas as pd
from numpy.random import randn
import matplotlib.pyplot as plt

d = pd.DataFrame({'one':randn(5), 'two':randn(5), 'three':randn(5), 'label':['label'] * 5},
        columns = ['one','two','three', 'label'])
bp= d.boxplot(by='label', rot=45)
plt.savefig('xxx.png')
```

Output produced:
![xxx](https://f.cloud.github.com/assets/128034/1884064/fcb7cd40-7993-11e3-8a07-58d7613407e2.png)

Issue:
The label on the left is rotated but the label on the right is not.

Versions: 
pandas '0.12.0'
matplotlib '1.3.1'



Discussion:
@saffsd if you'd like to submit a PR to correct this would be great.


Resolving patch:
diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py
--- 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:]:


Test patch:
diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py
--- 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')