@@ -2478,23 +2478,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
24782478 kwds : other plotting keyword arguments
24792479 To be passed to hist function
24802480 """
2481- import matplotlib .pyplot as plt
24822481
24832482 if by is not None :
24842483 axes = grouped_hist (data , column = column , by = by , ax = ax , grid = grid , figsize = figsize ,
24852484 sharex = sharex , sharey = sharey , layout = layout , bins = bins ,
2485+ xlabelsize = xlabelsize , xrot = xrot , ylabelsize = ylabelsize , yrot = yrot ,
24862486 ** kwds )
2487-
2488- for ax in axes .ravel ():
2489- if xlabelsize is not None :
2490- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2491- if xrot is not None :
2492- plt .setp (ax .get_xticklabels (), rotation = xrot )
2493- if ylabelsize is not None :
2494- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2495- if yrot is not None :
2496- plt .setp (ax .get_yticklabels (), rotation = yrot )
2497-
24982487 return axes
24992488
25002489 if column is not None :
@@ -2510,21 +2499,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
25102499
25112500 for i , col in enumerate (com ._try_sort (data .columns )):
25122501 ax = axes [i // ncols , i % ncols ]
2513- ax .xaxis .set_visible (True )
2514- ax .yaxis .set_visible (True )
25152502 ax .hist (data [col ].dropna ().values , bins = bins , ** kwds )
25162503 ax .set_title (col )
25172504 ax .grid (grid )
25182505
2519- if xlabelsize is not None :
2520- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2521- if xrot is not None :
2522- plt .setp (ax .get_xticklabels (), rotation = xrot )
2523- if ylabelsize is not None :
2524- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2525- if yrot is not None :
2526- plt .setp (ax .get_yticklabels (), rotation = yrot )
2527-
2506+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2507+ ylabelsize = ylabelsize , yrot = yrot )
25282508 fig .subplots_adjust (wspace = 0.3 , hspace = 0.3 )
25292509
25302510 return axes
@@ -2584,23 +2564,18 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
25842564 ax .hist (values , bins = bins , ** kwds )
25852565 ax .grid (grid )
25862566 axes = np .array ([ax ])
2567+
2568+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2569+ ylabelsize = ylabelsize , yrot = yrot )
2570+
25872571 else :
25882572 if 'figure' in kwds :
25892573 raise ValueError ("Cannot pass 'figure' when using the "
25902574 "'by' argument, since a new 'Figure' instance "
25912575 "will be created" )
2592- axes = grouped_hist (self , by = by , ax = ax , grid = grid , figsize = figsize ,
2593- bins = bins , ** kwds )
2594-
2595- for ax in axes .ravel ():
2596- if xlabelsize is not None :
2597- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2598- if xrot is not None :
2599- plt .setp (ax .get_xticklabels (), rotation = xrot )
2600- if ylabelsize is not None :
2601- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2602- if yrot is not None :
2603- plt .setp (ax .get_yticklabels (), rotation = yrot )
2576+ axes = grouped_hist (self , by = by , ax = ax , grid = grid , figsize = figsize , bins = bins ,
2577+ xlabelsize = xlabelsize , xrot = xrot , ylabelsize = ylabelsize , yrot = yrot ,
2578+ ** kwds )
26042579
26052580 if axes .ndim == 1 and len (axes ) == 1 :
26062581 return axes [0 ]
@@ -2609,6 +2584,7 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
26092584
26102585def grouped_hist (data , column = None , by = None , ax = None , bins = 50 , figsize = None ,
26112586 layout = None , sharex = False , sharey = False , rot = 90 , grid = True ,
2587+ xlabelsize = None , xrot = None , ylabelsize = None , yrot = None ,
26122588 ** kwargs ):
26132589 """
26142590 Grouped histogram
@@ -2635,9 +2611,15 @@ def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None,
26352611 def plot_group (group , ax ):
26362612 ax .hist (group .dropna ().values , bins = bins , ** kwargs )
26372613
2614+ xrot = xrot or rot
2615+
26382616 fig , axes = _grouped_plot (plot_group , data , column = column ,
26392617 by = by , sharex = sharex , sharey = sharey ,
26402618 figsize = figsize , layout = layout , rot = rot )
2619+
2620+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2621+ ylabelsize = ylabelsize , yrot = yrot )
2622+
26412623 fig .subplots_adjust (bottom = 0.15 , top = 0.9 , left = 0.1 , right = 0.9 ,
26422624 hspace = 0.5 , wspace = 0.3 )
26432625 return axes
@@ -3044,6 +3026,22 @@ def _get_xlim(lines):
30443026 return left , right
30453027
30463028
3029+ def _set_ticks_props (axes , xlabelsize = None , xrot = None ,
3030+ ylabelsize = None , yrot = None ):
3031+ import matplotlib .pyplot as plt
3032+
3033+ for ax in _flatten (axes ):
3034+ if xlabelsize is not None :
3035+ plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
3036+ if xrot is not None :
3037+ plt .setp (ax .get_xticklabels (), rotation = xrot )
3038+ if ylabelsize is not None :
3039+ plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
3040+ if yrot is not None :
3041+ plt .setp (ax .get_yticklabels (), rotation = yrot )
3042+ return axes
3043+
3044+
30473045if __name__ == '__main__' :
30483046 # import pandas.rpy.common as com
30493047 # sales = com.load_data('sanfrancisco.home.sales', package='nutshell')
0 commit comments