@@ -2689,6 +2689,18 @@ def test_line_colors(self):
2689
2689
self ._check_colors (ax .get_lines (), linecolors = ['red' ] * 5 )
2690
2690
tm .close ()
2691
2691
2692
+ # GH 10299
2693
+ custom_colors = ['#FF0000' , '#0000FF' , '#FFFF00' , '#000000' , '#FFFFFF' ]
2694
+ ax = df .plot (color = custom_colors )
2695
+ self ._check_colors (ax .get_lines (), linecolors = custom_colors )
2696
+ tm .close ()
2697
+
2698
+ with tm .assertRaises (ValueError ):
2699
+ # Color contains shorthand hex value results in ValueError
2700
+ custom_colors = ['#F00' , '#00F' , '#FF0' , '#000' , '#FFF' ]
2701
+ # Forced show plot
2702
+ _check_plot_works (df .plot , color = custom_colors )
2703
+
2692
2704
@slow
2693
2705
def test_line_colors_and_styles_subplots (self ):
2694
2706
# GH 9894
@@ -2725,6 +2737,20 @@ def test_line_colors_and_styles_subplots(self):
2725
2737
self ._check_colors (ax .get_lines (), linecolors = [c ])
2726
2738
tm .close ()
2727
2739
2740
+ # GH 10299
2741
+ custom_colors = ['#FF0000' , '#0000FF' , '#FFFF00' , '#000000' , '#FFFFFF' ]
2742
+ axes = df .plot (color = custom_colors , subplots = True )
2743
+ for ax , c in zip (axes , list (custom_colors )):
2744
+ self ._check_colors (ax .get_lines (), linecolors = [c ])
2745
+ tm .close ()
2746
+
2747
+ with tm .assertRaises (ValueError ):
2748
+ # Color contains shorthand hex value results in ValueError
2749
+ custom_colors = ['#F00' , '#00F' , '#FF0' , '#000' , '#FFF' ]
2750
+ # Forced show plot
2751
+ _check_plot_works (df .plot , color = custom_colors , subplots = True ,
2752
+ filterwarnings = 'ignore' )
2753
+
2728
2754
rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2729
2755
for cmap in ['jet' , cm .jet ]:
2730
2756
axes = df .plot (colormap = cmap , subplots = True )
0 commit comments