@@ -2501,23 +2501,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
25012501 kwds : other plotting keyword arguments
25022502 To be passed to hist function
25032503 """
2504- import matplotlib .pyplot as plt
25052504
25062505 if by is not None :
25072506 axes = grouped_hist (data , column = column , by = by , ax = ax , grid = grid , figsize = figsize ,
25082507 sharex = sharex , sharey = sharey , layout = layout , bins = bins ,
2508+ xlabelsize = xlabelsize , xrot = xrot , ylabelsize = ylabelsize , yrot = yrot ,
25092509 ** kwds )
2510-
2511- for ax in axes .ravel ():
2512- if xlabelsize is not None :
2513- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2514- if xrot is not None :
2515- plt .setp (ax .get_xticklabels (), rotation = xrot )
2516- if ylabelsize is not None :
2517- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2518- if yrot is not None :
2519- plt .setp (ax .get_yticklabels (), rotation = yrot )
2520-
25212510 return axes
25222511
25232512 if column is not None :
@@ -2533,21 +2522,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
25332522
25342523 for i , col in enumerate (com ._try_sort (data .columns )):
25352524 ax = axes [i // ncols , i % ncols ]
2536- ax .xaxis .set_visible (True )
2537- ax .yaxis .set_visible (True )
25382525 ax .hist (data [col ].dropna ().values , bins = bins , ** kwds )
25392526 ax .set_title (col )
25402527 ax .grid (grid )
25412528
2542- if xlabelsize is not None :
2543- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2544- if xrot is not None :
2545- plt .setp (ax .get_xticklabels (), rotation = xrot )
2546- if ylabelsize is not None :
2547- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2548- if yrot is not None :
2549- plt .setp (ax .get_yticklabels (), rotation = yrot )
2550-
2529+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2530+ ylabelsize = ylabelsize , yrot = yrot )
25512531 fig .subplots_adjust (wspace = 0.3 , hspace = 0.3 )
25522532
25532533 return axes
@@ -2607,23 +2587,18 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
26072587 ax .hist (values , bins = bins , ** kwds )
26082588 ax .grid (grid )
26092589 axes = np .array ([ax ])
2590+
2591+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2592+ ylabelsize = ylabelsize , yrot = yrot )
2593+
26102594 else :
26112595 if 'figure' in kwds :
26122596 raise ValueError ("Cannot pass 'figure' when using the "
26132597 "'by' argument, since a new 'Figure' instance "
26142598 "will be created" )
2615- axes = grouped_hist (self , by = by , ax = ax , grid = grid , figsize = figsize ,
2616- bins = bins , ** kwds )
2617-
2618- for ax in axes .ravel ():
2619- if xlabelsize is not None :
2620- plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
2621- if xrot is not None :
2622- plt .setp (ax .get_xticklabels (), rotation = xrot )
2623- if ylabelsize is not None :
2624- plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
2625- if yrot is not None :
2626- plt .setp (ax .get_yticklabels (), rotation = yrot )
2599+ axes = grouped_hist (self , by = by , ax = ax , grid = grid , figsize = figsize , bins = bins ,
2600+ xlabelsize = xlabelsize , xrot = xrot , ylabelsize = ylabelsize , yrot = yrot ,
2601+ ** kwds )
26272602
26282603 if axes .ndim == 1 and len (axes ) == 1 :
26292604 return axes [0 ]
@@ -2632,6 +2607,7 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
26322607
26332608def grouped_hist (data , column = None , by = None , ax = None , bins = 50 , figsize = None ,
26342609 layout = None , sharex = False , sharey = False , rot = 90 , grid = True ,
2610+ xlabelsize = None , xrot = None , ylabelsize = None , yrot = None ,
26352611 ** kwargs ):
26362612 """
26372613 Grouped histogram
@@ -2658,9 +2634,15 @@ def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None,
26582634 def plot_group (group , ax ):
26592635 ax .hist (group .dropna ().values , bins = bins , ** kwargs )
26602636
2637+ xrot = xrot or rot
2638+
26612639 fig , axes = _grouped_plot (plot_group , data , column = column ,
26622640 by = by , sharex = sharex , sharey = sharey ,
26632641 figsize = figsize , layout = layout , rot = rot )
2642+
2643+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2644+ ylabelsize = ylabelsize , yrot = yrot )
2645+
26642646 fig .subplots_adjust (bottom = 0.15 , top = 0.9 , left = 0.1 , right = 0.9 ,
26652647 hspace = 0.5 , wspace = 0.3 )
26662648 return axes
@@ -3094,6 +3076,22 @@ def _get_xlim(lines):
30943076 return left , right
30953077
30963078
3079+ def _set_ticks_props (axes , xlabelsize = None , xrot = None ,
3080+ ylabelsize = None , yrot = None ):
3081+ import matplotlib .pyplot as plt
3082+
3083+ for ax in _flatten (axes ):
3084+ if xlabelsize is not None :
3085+ plt .setp (ax .get_xticklabels (), fontsize = xlabelsize )
3086+ if xrot is not None :
3087+ plt .setp (ax .get_xticklabels (), rotation = xrot )
3088+ if ylabelsize is not None :
3089+ plt .setp (ax .get_yticklabels (), fontsize = ylabelsize )
3090+ if yrot is not None :
3091+ plt .setp (ax .get_yticklabels (), rotation = yrot )
3092+ return axes
3093+
3094+
30973095if __name__ == '__main__' :
30983096 # import pandas.rpy.common as com
30993097 # sales = com.load_data('sanfrancisco.home.sales', package='nutshell')
0 commit comments