@@ -2836,6 +2836,55 @@ def test_line_colors(self):
2836
2836
ax = df .ix [:, [0 ]].plot (color = 'DodgerBlue' )
2837
2837
self ._check_colors (ax .lines , linecolors = ['DodgerBlue' ])
2838
2838
2839
+ @slow
2840
+ def test_line_colors_and_styles_subplots (self ):
2841
+ from matplotlib import cm
2842
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2843
+
2844
+ df = DataFrame (randn (5 , 5 ))
2845
+
2846
+ axes = df .plot (subplots = True )
2847
+ for ax , c in zip (axes , list (default_colors )):
2848
+ self ._check_colors (ax .get_lines (), linecolors = c )
2849
+ tm .close ()
2850
+
2851
+ # single color
2852
+ axes = df .plot (subplots = True , color = 'k' )
2853
+ for ax in axes :
2854
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
2855
+ tm .close ()
2856
+
2857
+ custom_colors = 'rgcby'
2858
+ axes = df .plot (color = custom_colors , subplots = True )
2859
+ for ax , c in zip (axes , list (custom_colors )):
2860
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2861
+ tm .close ()
2862
+
2863
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2864
+ for cmap in ['jet' , cm .jet ]:
2865
+ axes = df .plot (colormap = cmap , subplots = True )
2866
+ for ax , c in zip (axes , rgba_colors ):
2867
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2868
+ tm .close ()
2869
+
2870
+ # make color a list if plotting one column frame
2871
+ # handles cases like df.plot(color='DodgerBlue')
2872
+ axes = df .ix [:, [0 ]].plot (color = 'DodgerBlue' , subplots = True )
2873
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
2874
+
2875
+ # single character style
2876
+ axes = df .plot (style = 'r' , subplots = True )
2877
+ for ax in axes :
2878
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
2879
+ tm .close ()
2880
+
2881
+ # list of styles
2882
+ styles = list ('rgcby' )
2883
+ axes = df .plot (style = styles , subplots = True )
2884
+ for ax , c in zip (axes , styles ):
2885
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2886
+ tm .close ()
2887
+
2839
2888
@slow
2840
2889
def test_area_colors (self ):
2841
2890
from matplotlib import cm
@@ -2934,6 +2983,58 @@ def test_kde_colors(self):
2934
2983
rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2935
2984
self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
2936
2985
2986
+ @slow
2987
+ def test_kde_colors_and_styles_subplots (self ):
2988
+ tm ._skip_if_no_scipy ()
2989
+ _skip_if_no_scipy_gaussian_kde ()
2990
+
2991
+ from matplotlib import cm
2992
+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2993
+
2994
+ df = DataFrame (randn (5 , 5 ))
2995
+
2996
+ axes = df .plot (kind = 'kde' , subplots = True )
2997
+ for ax , c in zip (axes , list (default_colors )):
2998
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2999
+ tm .close ()
3000
+
3001
+ # single color
3002
+ axes = df .plot (kind = 'kde' , color = 'k' , subplots = True )
3003
+ for ax in axes :
3004
+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
3005
+ tm .close ()
3006
+
3007
+ custom_colors = 'rgcby'
3008
+ axes = df .plot (kind = 'kde' , color = custom_colors , subplots = True )
3009
+ for ax , c in zip (axes , list (custom_colors )):
3010
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3011
+ tm .close ()
3012
+
3013
+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
3014
+ for cmap in ['jet' , cm .jet ]:
3015
+ axes = df .plot (kind = 'kde' , colormap = cmap , subplots = True )
3016
+ for ax , c in zip (axes , rgba_colors ):
3017
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3018
+ tm .close ()
3019
+
3020
+ # make color a list if plotting one column frame
3021
+ # handles cases like df.plot(color='DodgerBlue')
3022
+ axes = df .ix [:, [0 ]].plot (kind = 'kde' , color = 'DodgerBlue' , subplots = True )
3023
+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
3024
+
3025
+ # single character style
3026
+ axes = df .plot (kind = 'kde' , style = 'r' , subplots = True )
3027
+ for ax in axes :
3028
+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
3029
+ tm .close ()
3030
+
3031
+ # list of styles
3032
+ styles = list ('rgcby' )
3033
+ axes = df .plot (kind = 'kde' , style = styles , subplots = True )
3034
+ for ax , c in zip (axes , styles ):
3035
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
3036
+ tm .close ()
3037
+
2937
3038
@slow
2938
3039
def test_boxplot_colors (self ):
2939
3040
0 commit comments