@@ -2592,6 +2592,67 @@ def test_line_colors(self):
25922592 self ._check_colors (ax .get_lines (), linecolors = ['red' ] * 5 )
25932593 tm .close ()
25942594
2595+ @slow
2596+ def test_line_colors_and_styles_subplots (self ):
2597+ # GH 9894
2598+ from matplotlib import cm
2599+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2600+
2601+ df = DataFrame (randn (5 , 5 ))
2602+
2603+ axes = df .plot (subplots = True )
2604+ for ax , c in zip (axes , list (default_colors )):
2605+ self ._check_colors (ax .get_lines (), linecolors = c )
2606+ tm .close ()
2607+
2608+ # single color char
2609+ axes = df .plot (subplots = True , color = 'k' )
2610+ for ax in axes :
2611+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
2612+ tm .close ()
2613+
2614+ # single color str
2615+ axes = df .plot (subplots = True , color = 'green' )
2616+ for ax in axes :
2617+ self ._check_colors (ax .get_lines (), linecolors = ['green' ])
2618+ tm .close ()
2619+
2620+ custom_colors = 'rgcby'
2621+ axes = df .plot (color = custom_colors , subplots = True )
2622+ for ax , c in zip (axes , list (custom_colors )):
2623+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2624+ tm .close ()
2625+
2626+ axes = df .plot (color = list (custom_colors ), subplots = True )
2627+ for ax , c in zip (axes , list (custom_colors )):
2628+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2629+ tm .close ()
2630+
2631+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2632+ for cmap in ['jet' , cm .jet ]:
2633+ axes = df .plot (colormap = cmap , subplots = True )
2634+ for ax , c in zip (axes , rgba_colors ):
2635+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2636+ tm .close ()
2637+
2638+ # make color a list if plotting one column frame
2639+ # handles cases like df.plot(color='DodgerBlue')
2640+ axes = df .ix [:, [0 ]].plot (color = 'DodgerBlue' , subplots = True )
2641+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
2642+
2643+ # single character style
2644+ axes = df .plot (style = 'r' , subplots = True )
2645+ for ax in axes :
2646+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
2647+ tm .close ()
2648+
2649+ # list of styles
2650+ styles = list ('rgcby' )
2651+ axes = df .plot (style = styles , subplots = True )
2652+ for ax , c in zip (axes , styles ):
2653+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2654+ tm .close ()
2655+
25952656 @slow
25962657 def test_area_colors (self ):
25972658 from matplotlib import cm
@@ -2694,6 +2755,64 @@ def test_kde_colors(self):
26942755 rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
26952756 self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
26962757
2758+ @slow
2759+ def test_kde_colors_and_styles_subplots (self ):
2760+ tm ._skip_if_no_scipy ()
2761+ _skip_if_no_scipy_gaussian_kde ()
2762+
2763+ from matplotlib import cm
2764+ default_colors = self .plt .rcParams .get ('axes.color_cycle' )
2765+
2766+ df = DataFrame (randn (5 , 5 ))
2767+
2768+ axes = df .plot (kind = 'kde' , subplots = True )
2769+ for ax , c in zip (axes , list (default_colors )):
2770+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2771+ tm .close ()
2772+
2773+ # single color char
2774+ axes = df .plot (kind = 'kde' , color = 'k' , subplots = True )
2775+ for ax in axes :
2776+ self ._check_colors (ax .get_lines (), linecolors = ['k' ])
2777+ tm .close ()
2778+
2779+ # single color str
2780+ axes = df .plot (kind = 'kde' , color = 'red' , subplots = True )
2781+ for ax in axes :
2782+ self ._check_colors (ax .get_lines (), linecolors = ['red' ])
2783+ tm .close ()
2784+
2785+ custom_colors = 'rgcby'
2786+ axes = df .plot (kind = 'kde' , color = custom_colors , subplots = True )
2787+ for ax , c in zip (axes , list (custom_colors )):
2788+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2789+ tm .close ()
2790+
2791+ rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2792+ for cmap in ['jet' , cm .jet ]:
2793+ axes = df .plot (kind = 'kde' , colormap = cmap , subplots = True )
2794+ for ax , c in zip (axes , rgba_colors ):
2795+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2796+ tm .close ()
2797+
2798+ # make color a list if plotting one column frame
2799+ # handles cases like df.plot(color='DodgerBlue')
2800+ axes = df .ix [:, [0 ]].plot (kind = 'kde' , color = 'DodgerBlue' , subplots = True )
2801+ self ._check_colors (axes [0 ].lines , linecolors = ['DodgerBlue' ])
2802+
2803+ # single character style
2804+ axes = df .plot (kind = 'kde' , style = 'r' , subplots = True )
2805+ for ax in axes :
2806+ self ._check_colors (ax .get_lines (), linecolors = ['r' ])
2807+ tm .close ()
2808+
2809+ # list of styles
2810+ styles = list ('rgcby' )
2811+ axes = df .plot (kind = 'kde' , style = styles , subplots = True )
2812+ for ax , c in zip (axes , styles ):
2813+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2814+ tm .close ()
2815+
26972816 @slow
26982817 def test_boxplot_colors (self ):
26992818
0 commit comments