@@ -2501,23 +2501,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
2501
2501
kwds : other plotting keyword arguments
2502
2502
To be passed to hist function
2503
2503
"""
2504
- import matplotlib .pyplot as plt
2505
2504
2506
2505
if by is not None :
2507
2506
axes = grouped_hist (data , column = column , by = by , ax = ax , grid = grid , figsize = figsize ,
2508
2507
sharex = sharex , sharey = sharey , layout = layout , bins = bins ,
2508
+ xlabelsize = xlabelsize , xrot = xrot , ylabelsize = ylabelsize , yrot = yrot ,
2509
2509
** 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
-
2521
2510
return axes
2522
2511
2523
2512
if column is not None :
@@ -2533,21 +2522,12 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
2533
2522
2534
2523
for i , col in enumerate (com ._try_sort (data .columns )):
2535
2524
ax = axes [i // ncols , i % ncols ]
2536
- ax .xaxis .set_visible (True )
2537
- ax .yaxis .set_visible (True )
2538
2525
ax .hist (data [col ].dropna ().values , bins = bins , ** kwds )
2539
2526
ax .set_title (col )
2540
2527
ax .grid (grid )
2541
2528
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 )
2551
2531
fig .subplots_adjust (wspace = 0.3 , hspace = 0.3 )
2552
2532
2553
2533
return axes
@@ -2607,23 +2587,18 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
2607
2587
ax .hist (values , bins = bins , ** kwds )
2608
2588
ax .grid (grid )
2609
2589
axes = np .array ([ax ])
2590
+
2591
+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2592
+ ylabelsize = ylabelsize , yrot = yrot )
2593
+
2610
2594
else :
2611
2595
if 'figure' in kwds :
2612
2596
raise ValueError ("Cannot pass 'figure' when using the "
2613
2597
"'by' argument, since a new 'Figure' instance "
2614
2598
"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 )
2627
2602
2628
2603
if axes .ndim == 1 and len (axes ) == 1 :
2629
2604
return axes [0 ]
@@ -2632,6 +2607,7 @@ def hist_series(self, by=None, ax=None, grid=True, xlabelsize=None,
2632
2607
2633
2608
def grouped_hist (data , column = None , by = None , ax = None , bins = 50 , figsize = None ,
2634
2609
layout = None , sharex = False , sharey = False , rot = 90 , grid = True ,
2610
+ xlabelsize = None , xrot = None , ylabelsize = None , yrot = None ,
2635
2611
** kwargs ):
2636
2612
"""
2637
2613
Grouped histogram
@@ -2658,9 +2634,15 @@ def grouped_hist(data, column=None, by=None, ax=None, bins=50, figsize=None,
2658
2634
def plot_group (group , ax ):
2659
2635
ax .hist (group .dropna ().values , bins = bins , ** kwargs )
2660
2636
2637
+ xrot = xrot or rot
2638
+
2661
2639
fig , axes = _grouped_plot (plot_group , data , column = column ,
2662
2640
by = by , sharex = sharex , sharey = sharey ,
2663
2641
figsize = figsize , layout = layout , rot = rot )
2642
+
2643
+ _set_ticks_props (axes , xlabelsize = xlabelsize , xrot = xrot ,
2644
+ ylabelsize = ylabelsize , yrot = yrot )
2645
+
2664
2646
fig .subplots_adjust (bottom = 0.15 , top = 0.9 , left = 0.1 , right = 0.9 ,
2665
2647
hspace = 0.5 , wspace = 0.3 )
2666
2648
return axes
@@ -3094,6 +3076,22 @@ def _get_xlim(lines):
3094
3076
return left , right
3095
3077
3096
3078
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
+
3097
3095
if __name__ == '__main__' :
3098
3096
# import pandas.rpy.common as com
3099
3097
# sales = com.load_data('sanfrancisco.home.sales', package='nutshell')
0 commit comments