@@ -2897,6 +2897,55 @@ def test_line_colors(self):
2897
2897
ax = df .ix [:, [0 ]].plot (color = 'DodgerBlue' )
2898
2898
self ._check_colors (ax .lines , linecolors = ['DodgerBlue' ])
2899
2899
2900
+ @slow
2901
+ def test_line_colors_and_styles_subplots (self ):
2902
+ from matplotlib import cm
2903
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2904
+
2905
+ df = DataFrame (randn (5 , 5 ))
2906
+
2907
+ axes = df .plot (subplots = True )
2908
+ for ax , c in zip (axes , list (default_colors )):
2909
+ self ._check_colors (ax .get_lines (), linecolors = c )
2910
+ tm .close ()
2911
+
2912
+ # single color
2913
+ axes = df .plot (subplots = True , color = 'k' )
2914
+ for ax in axes :
2915
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
2916
+ tm .close ()
2917
+
2918
+ custom_colors = 'rgcby'
2919
+ axes = df .plot (color = custom_colors , subplots = True )
2920
+ for ax , c in zip (axes , list (custom_colors )):
2921
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2922
+ tm .close ()
2923
+
2924
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2925
+ for cmap in ['jet' , cm .jet ]:
2926
+ axes = df .plot (colormap = cmap , subplots = True )
2927
+ for ax , c in zip (axes , rgba_colors ):
2928
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2929
+ tm .close ()
2930
+
2931
+ # make color a list if plotting one column frame
2932
+ # handles cases like df.plot(color='DodgerBlue')
2933
+ axes = df .ix [:, [0 ]].plot (color = 'DodgerBlue' , subplots = True )
2934
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
2935
+
2936
+ # single character style
2937
+ axes = df .plot (style = 'r' , subplots = True )
2938
+ for ax in axes :
2939
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
2940
+ tm .close ()
2941
+
2942
+ # list of styles
2943
+ styles = list ('rgcby' )
2944
+ axes = df .plot (style = styles , subplots = True )
2945
+ for ax , c in zip (axes , styles ):
2946
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2947
+ tm .close ()
2948
+
2900
2949
@slow
2901
2950
def test_area_colors (self ):
2902
2951
from matplotlib import cm
@@ -2995,6 +3044,58 @@ def test_kde_colors(self):
2995
3044
rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2996
3045
self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
2997
3046
3047
+ @slow
3048
+ def test_kde_colors_and_styles_subplots (self ):
3049
+ tm ._skip_if_no_scipy ()
3050
+ _skip_if_no_scipy_gaussian_kde ()
3051
+
3052
+ from matplotlib import cm
3053
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
3054
+
3055
+ df = DataFrame (randn (5 , 5 ))
3056
+
3057
+ axes = df .plot (kind = 'kde' , subplots = True )
3058
+ for ax , c in zip (axes , list (default_colors )):
3059
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3060
+ tm .close ()
3061
+
3062
+ # single color
3063
+ axes = df .plot (kind = 'kde' , color = 'k' , subplots = True )
3064
+ for ax in axes :
3065
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
3066
+ tm .close ()
3067
+
3068
+ custom_colors = 'rgcby'
3069
+ axes = df .plot (kind = 'kde' , color = custom_colors , subplots = True )
3070
+ for ax , c in zip (axes , list (custom_colors )):
3071
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3072
+ tm .close ()
3073
+
3074
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
3075
+ for cmap in ['jet' , cm .jet ]:
3076
+ axes = df .plot (kind = 'kde' , colormap = cmap , subplots = True )
3077
+ for ax , c in zip (axes , rgba_colors ):
3078
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3079
+ tm .close ()
3080
+
3081
+ # make color a list if plotting one column frame
3082
+ # handles cases like df.plot(color='DodgerBlue')
3083
+ axes = df .ix [:, [0 ]].plot (kind = 'kde' , color = 'DodgerBlue' , subplots = True )
3084
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
3085
+
3086
+ # single character style
3087
+ axes = df .plot (kind = 'kde' , style = 'r' , subplots = True )
3088
+ for ax in axes :
3089
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
3090
+ tm .close ()
3091
+
3092
+ # list of styles
3093
+ styles = list ('rgcby' )
3094
+ axes = df .plot (kind = 'kde' , style = styles , subplots = True )
3095
+ for ax , c in zip (axes , styles ):
3096
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3097
+ tm .close ()
3098
+
2998
3099
@slow
2999
3100
def test_boxplot_colors (self ):
3000
3101
0 commit comments