@@ -1718,15 +1718,15 @@ def test_hist_df_coord(self):
1718
1718
normal_df = DataFrame ({'A' : np .repeat (np .array ([1 , 2 , 3 , 4 , 5 ]),
1719
1719
np .array ([10 , 9 , 8 , 7 , 6 ])),
1720
1720
'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 ])),
1722
1722
'C' : np .repeat (np .array ([1 , 2 , 3 , 4 , 5 ]),
1723
1723
np .array ([6 , 7 , 8 , 9 , 10 ]))},
1724
1724
columns = ['A' , 'B' , 'C' ])
1725
1725
1726
1726
nan_df = DataFrame ({'A' : np .repeat (np .array ([np .nan , 1 , 2 , 3 , 4 , 5 ]),
1727
1727
np .array ([3 , 10 , 9 , 8 , 7 , 6 ])),
1728
1728
'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 ])),
1730
1730
'C' : np .repeat (np .array ([1 , 2 , 3 , np .nan , 4 , 5 ]),
1731
1731
np .array ([6 , 7 , 8 , 3 , 9 , 10 ]))},
1732
1732
columns = ['A' , 'B' , 'C' ])
@@ -2157,20 +2157,38 @@ def test_area_colors(self):
2157
2157
self ._check_colors (ax .get_lines (), linecolors = custom_colors )
2158
2158
poly = [o for o in ax .get_children () if isinstance (o , PolyCollection )]
2159
2159
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 )
2160
2166
tm .close ()
2161
2167
2162
2168
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 )
2165
2171
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 )
2167
2178
tm .close ()
2168
2179
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 )
2172
2183
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 )
2174
2192
2175
2193
@slow
2176
2194
def test_hist_colors (self ):
0 commit comments