@@ -2859,6 +2859,55 @@ def test_line_colors(self):
2859
2859
ax = df .ix [:, [0 ]].plot (color = 'DodgerBlue' )
2860
2860
self ._check_colors (ax .lines , linecolors = ['DodgerBlue' ])
2861
2861
2862
+ @slow
2863
+ def test_line_colors_and_styles_subplots (self ):
2864
+ from matplotlib import cm
2865
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2866
+
2867
+ df = DataFrame (randn (5 , 5 ))
2868
+
2869
+ axes = df .plot (subplots = True )
2870
+ for ax , c in zip (axes , list (default_colors )):
2871
+ self ._check_colors (ax .get_lines (), linecolors = c )
2872
+ tm .close ()
2873
+
2874
+ # single color
2875
+ axes = df .plot (subplots = True , color = 'k' )
2876
+ for ax in axes :
2877
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
2878
+ tm .close ()
2879
+
2880
+ custom_colors = 'rgcby'
2881
+ axes = df .plot (color = custom_colors , subplots = True )
2882
+ for ax , c in zip (axes , list (custom_colors )):
2883
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2884
+ tm .close ()
2885
+
2886
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2887
+ for cmap in ['jet' , cm .jet ]:
2888
+ axes = df .plot (colormap = cmap , subplots = True )
2889
+ for ax , c in zip (axes , rgba_colors ):
2890
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2891
+ tm .close ()
2892
+
2893
+ # make color a list if plotting one column frame
2894
+ # handles cases like df.plot(color='DodgerBlue')
2895
+ axes = df .ix [:, [0 ]].plot (color = 'DodgerBlue' , subplots = True )
2896
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
2897
+
2898
+ # single character style
2899
+ axes = df .plot (style = 'r' , subplots = True )
2900
+ for ax in axes :
2901
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
2902
+ tm .close ()
2903
+
2904
+ # list of styles
2905
+ styles = list ('rgcby' )
2906
+ axes = df .plot (style = styles , subplots = True )
2907
+ for ax , c in zip (axes , styles ):
2908
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2909
+ tm .close ()
2910
+
2862
2911
@slow
2863
2912
def test_area_colors (self ):
2864
2913
from matplotlib import cm
@@ -2957,6 +3006,58 @@ def test_kde_colors(self):
2957
3006
rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2958
3007
self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
2959
3008
3009
+ @slow
3010
+ def test_kde_colors_and_styles_subplots (self ):
3011
+ tm ._skip_if_no_scipy ()
3012
+ _skip_if_no_scipy_gaussian_kde ()
3013
+
3014
+ from matplotlib import cm
3015
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
3016
+
3017
+ df = DataFrame (randn (5 , 5 ))
3018
+
3019
+ axes = df .plot (kind = 'kde' , subplots = True )
3020
+ for ax , c in zip (axes , list (default_colors )):
3021
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3022
+ tm .close ()
3023
+
3024
+ # single color
3025
+ axes = df .plot (kind = 'kde' , color = 'k' , subplots = True )
3026
+ for ax in axes :
3027
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
3028
+ tm .close ()
3029
+
3030
+ custom_colors = 'rgcby'
3031
+ axes = df .plot (kind = 'kde' , color = custom_colors , subplots = True )
3032
+ for ax , c in zip (axes , list (custom_colors )):
3033
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3034
+ tm .close ()
3035
+
3036
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
3037
+ for cmap in ['jet' , cm .jet ]:
3038
+ axes = df .plot (kind = 'kde' , colormap = cmap , subplots = True )
3039
+ for ax , c in zip (axes , rgba_colors ):
3040
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3041
+ tm .close ()
3042
+
3043
+ # make color a list if plotting one column frame
3044
+ # handles cases like df.plot(color='DodgerBlue')
3045
+ axes = df .ix [:, [0 ]].plot (kind = 'kde' , color = 'DodgerBlue' , subplots = True )
3046
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
3047
+
3048
+ # single character style
3049
+ axes = df .plot (kind = 'kde' , style = 'r' , subplots = True )
3050
+ for ax in axes :
3051
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
3052
+ tm .close ()
3053
+
3054
+ # list of styles
3055
+ styles = list ('rgcby' )
3056
+ axes = df .plot (kind = 'kde' , style = styles , subplots = True )
3057
+ for ax , c in zip (axes , styles ):
3058
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3059
+ tm .close ()
3060
+
2960
3061
@slow
2961
3062
def test_boxplot_colors (self ):
2962
3063
0 commit comments