Repository: pandas-dev/pandas

Issue:
BUG?: secondary_y is unaltered by fontsize parameter
Hi,

I have found that fontsize is ignored on the secondary_y axis in DataFrame.plot in version 17.1.  Is this by intention?  (Apologies, if this is the wrong place to ask this or if it has already been asked as I was unable to find it.)

Thanks!

Example:

``` python
>>> import pandas as pd, numpy as np, matplotlib.pyplot as plt
>>> x = pd.DataFrame(np.random.randn(100,2), columns=list('AB')).assign(C = lambda df: df.B.cumsum())
>>> x.plot(secondary_y='C', fontsize=20).legend(fontsize=16)
<matplotlib.legend.Legend object at 0x05F0B990>
>>> plt.show() # Righthand y axis remains small
```

Here are my package versions:

``` python
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 32
OS: Windows
OS-release: 8
machine: AMD64
processor: AMD64 Family 21 Model 16 Stepping 1, AuthenticAMD
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.17.1
nose: None
pip: 1.5.6
setuptools: 7.0
Cython: None
numpy: 1.9.3
scipy: 0.16.0
statsmodels: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.0
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None
```



Discussion:
Thanks, looks like a bug. Internally, `._apply_axis_properties` should be applied to secondary ax if exists. 

PR is appreciated!

I'm looking into this (scipy sprints 2017)

Resolving patch:
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -379,6 +379,11 @@ def _post_plot_logic_common(self, ax, data):
             self._apply_axis_properties(ax.xaxis, rot=self.rot,
                                         fontsize=self.fontsize)
             self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
+
+            if hasattr(ax, 'right_ax'):
+                self._apply_axis_properties(ax.right_ax.yaxis,
+                                            fontsize=self.fontsize)
+
         elif self.orientation == 'horizontal':
             if self._need_to_set_index:
                 yticklabels = [labels.get(y, '') for y in ax.get_yticks()]
@@ -386,6 +391,10 @@ def _post_plot_logic_common(self, ax, data):
             self._apply_axis_properties(ax.yaxis, rot=self.rot,
                                         fontsize=self.fontsize)
             self._apply_axis_properties(ax.xaxis, fontsize=self.fontsize)
+
+            if hasattr(ax, 'right_ax'):
+                self._apply_axis_properties(ax.right_ax.yaxis,
+                                            fontsize=self.fontsize)
         else:  # pragma no cover
             raise ValueError
 


Test patch:
diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py
--- a/pandas/tests/plotting/test_frame.py
+++ b/pandas/tests/plotting/test_frame.py
@@ -2733,6 +2733,23 @@ def test_rcParams_bar_colors(self):
                 barplot = pd.DataFrame([[1, 2, 3]]).plot(kind="bar")
         assert color_tuples == [c.get_facecolor() for c in barplot.patches]
 
+    @pytest.mark.parametrize('method', ['line', 'barh', 'bar'])
+    def test_secondary_axis_font_size(self, method):
+        # GH: 12565
+        df = (pd.DataFrame(np.random.randn(15, 2),
+                           columns=list('AB'))
+              .assign(C=lambda df: df.B.cumsum())
+              .assign(D=lambda df: df.C * 1.1))
+
+        fontsize = 20
+        sy = ['C', 'D']
+
+        kwargs = dict(secondary_y=sy, fontsize=fontsize,
+                      mark_right=True)
+        ax = getattr(df.plot, method)(**kwargs)
+        self._check_ticks_props(axes=ax.right_ax,
+                                ylabelsize=fontsize)
+
 
 def _generate_4_axes_via_gridspec():
     import matplotlib.pyplot as plt