@@ -1718,15 +1718,15 @@ def test_hist_df_coord(self):
17181718 normal_df = DataFrame ({'A' : np .repeat (np .array ([1 , 2 , 3 , 4 , 5 ]),
17191719 np .array ([10 , 9 , 8 , 7 , 6 ])),
17201720 'B' : np .repeat (np .array ([1 , 2 , 3 , 4 , 5 ]),
1721- np .array ([8 , 8 , 8 , 8 , 8 ])),
1721+ np .array ([8 , 8 , 8 , 8 , 8 ])),
17221722 'C' : np .repeat (np .array ([1 , 2 , 3 , 4 , 5 ]),
17231723 np .array ([6 , 7 , 8 , 9 , 10 ]))},
17241724 columns = ['A' , 'B' , 'C' ])
17251725
17261726 nan_df = DataFrame ({'A' : np .repeat (np .array ([np .nan , 1 , 2 , 3 , 4 , 5 ]),
17271727 np .array ([3 , 10 , 9 , 8 , 7 , 6 ])),
17281728 'B' : np .repeat (np .array ([1 , np .nan , 2 , 3 , 4 , 5 ]),
1729- np .array ([8 , 3 , 8 , 8 , 8 , 8 ])),
1729+ np .array ([8 , 3 , 8 , 8 , 8 , 8 ])),
17301730 'C' : np .repeat (np .array ([1 , 2 , 3 , np .nan , 4 , 5 ]),
17311731 np .array ([6 , 7 , 8 , 3 , 9 , 10 ]))},
17321732 columns = ['A' , 'B' , 'C' ])
@@ -2157,20 +2157,38 @@ def test_area_colors(self):
21572157 self ._check_colors (ax .get_lines (), linecolors = custom_colors )
21582158 poly = [o for o in ax .get_children () if isinstance (o , PolyCollection )]
21592159 self ._check_colors (poly , facecolors = custom_colors )
2160+
2161+ handles , labels = ax .get_legend_handles_labels ()
2162+ # legend is stored as Line2D, thus check linecolors
2163+ self ._check_colors (handles , linecolors = custom_colors )
2164+ for h in handles :
2165+ self .assertTrue (h .get_alpha () is None )
21602166 tm .close ()
21612167
21622168 ax = df .plot (kind = 'area' , colormap = 'jet' )
2163- rgba_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2164- self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
2169+ jet_colors = lmap (cm .jet , np .linspace (0 , 1 , len (df )))
2170+ self ._check_colors (ax .get_lines (), linecolors = jet_colors )
21652171 poly = [o for o in ax .get_children () if isinstance (o , PolyCollection )]
2166- self ._check_colors (poly , facecolors = rgba_colors )
2172+ self ._check_colors (poly , facecolors = jet_colors )
2173+
2174+ handles , labels = ax .get_legend_handles_labels ()
2175+ self ._check_colors (handles , linecolors = jet_colors )
2176+ for h in handles :
2177+ self .assertTrue (h .get_alpha () is None )
21672178 tm .close ()
21682179
2169- ax = df . plot ( kind = 'area' , colormap = cm . jet )
2170- rgba_colors = lmap ( cm .jet , np . linspace ( 0 , 1 , len ( df )) )
2171- self ._check_colors (ax .get_lines (), linecolors = rgba_colors )
2180+ # When stacked=True, alpha is set to 0.5
2181+ ax = df . plot ( kind = 'area' , colormap = cm .jet , stacked = False )
2182+ self ._check_colors (ax .get_lines (), linecolors = jet_colors )
21722183 poly = [o for o in ax .get_children () if isinstance (o , PolyCollection )]
2173- self ._check_colors (poly , facecolors = rgba_colors )
2184+ jet_with_alpha = [(c [0 ], c [1 ], c [2 ], 0.5 ) for c in jet_colors ]
2185+ self ._check_colors (poly , facecolors = jet_with_alpha )
2186+
2187+ handles , labels = ax .get_legend_handles_labels ()
2188+ # Line2D can't have alpha in its linecolor
2189+ self ._check_colors (handles , linecolors = jet_colors )
2190+ for h in handles :
2191+ self .assertEqual (h .get_alpha (), 0.5 )
21742192
21752193 @slow
21762194 def test_hist_colors (self ):
0 commit comments