Repository: pandas-dev/pandas

Issue:
DataFrame.hist ignores keyword arguments
`DataFrame.hist` allows arbitrary keyword arguments which (according to the docstring) are passed to `matplotlib.hist`, however, it ignores keyword arguments in `pandas.tools.plotting.grouped_hist` (does not pass them to `hist`). 

This would be useful in order to create normalized and/or cumulative histograms. 
It requires just a minor fix - if you want I can submit a PR.



Discussion:
Please do


Resolving patch:
diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py
--- a/pandas/tools/plotting.py
+++ b/pandas/tools/plotting.py
@@ -645,9 +645,9 @@ def r(h):
     return ax
 
 
-def grouped_hist(data, column=None, by=None, ax=None, bins=50, log=False,
+def grouped_hist(data, column=None, by=None, ax=None, bins=50,
                  figsize=None, layout=None, sharex=False, sharey=False,
-                 rot=90, **kwargs):
+                 rot=90, grid=True, **kwargs):
     """
     Grouped histogram
 
@@ -658,19 +658,20 @@ def grouped_hist(data, column=None, by=None, ax=None, bins=50, log=False,
     by: object, optional
     ax: axes, optional
     bins: int, default 50
-    log: boolean, default False
     figsize: tuple, optional
     layout: optional
     sharex: boolean, default False
     sharey: boolean, default False
     rot: int, default 90
+    grid: bool, default True
+    kwargs: dict, keyword arguments passed to matplotlib.Axes.hist
 
     Returns
     -------
     axes: collection of Matplotlib Axes
     """
     def plot_group(group, ax):
-        ax.hist(group.dropna().values, bins=bins)
+        ax.hist(group.dropna().values, bins=bins, **kwargs)
 
     fig, axes = _grouped_plot(plot_group, data, column=column,
                               by=by, sharex=sharex, sharey=sharey,


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
@@ -442,6 +442,7 @@ def test_kde(self):
 
     @slow
     def test_hist(self):
+        import matplotlib.pyplot as plt
         df = DataFrame(np.random.randn(100, 4))
         _check_plot_works(df.hist)
         _check_plot_works(df.hist, grid=False)
@@ -462,7 +463,7 @@ def test_hist(self):
         # make sure sharex, sharey is handled
         _check_plot_works(df.hist, sharex=True, sharey=True)
 
-        # make sure kwargs are handled
+        # make sure xlabelsize and xrot are handled
         ser = df[0]
         xf, yf = 20, 20
         xrot, yrot = 30, 30
@@ -486,6 +487,21 @@ def test_hist(self):
                 self.assertAlmostEqual(xtick.get_fontsize(), xf)
                 self.assertAlmostEqual(xtick.get_rotation(), xrot)
 
+        plt.close('all')
+        # make sure kwargs to hist are handled
+        ax = ser.hist(normed=True, cumulative=True, bins=4)
+        # height of last bin (index 5) must be 1.0
+        self.assertAlmostEqual(ax.get_children()[5].get_height(), 1.0)
+
+        plt.close('all')
+        ax = ser.hist(log=True)
+        # scale of y must be 'log'
+        self.assert_(ax.get_yscale() == 'log')
+
+        plt.close('all')
+        # propagate attr exception from matplotlib.Axes.hist
+        self.assertRaises(AttributeError, ser.hist, foo='bar')
+
     @slow
     def test_scatter(self):
         _skip_if_no_scipy()
@@ -724,6 +740,28 @@ def test_grouped_hist(self):
         for ax in axes.ravel():
             self.assert_(len(ax.patches) > 0)
 
+        plt.close('all')
+        # make sure kwargs to hist are handled
+        axes = plotting.grouped_hist(df.A, by=df.C, normed=True,
+                                     cumulative=True, bins=4)
+
+        # height of last bin (index 5) must be 1.0
+        for ax in axes.ravel():
+            height = ax.get_children()[5].get_height()
+            self.assertAlmostEqual(height, 1.0)
+
+        plt.close('all')
+        axes = plotting.grouped_hist(df.A, by=df.C, log=True)
+        # scale of y must be 'log'
+        for ax in axes.ravel():
+            self.assert_(ax.get_yscale() == 'log')
+
+        plt.close('all')
+        # propagate attr exception from matplotlib.Axes.hist
+        self.assertRaises(AttributeError, plotting.grouped_hist, df.A,
+                          by=df.C, foo='bar')
+
+
     def test_option_mpl_style(self):
         # just a sanity check
         try: