44from matplotlib .externals import six
55from matplotlib .externals .six .moves import reduce , xrange , zip , zip_longest
66
7+ import itertools
78import math
89import warnings
910
@@ -2457,7 +2458,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
24572458 Call signature::
24582459
24592460 pie(x, explode=None, labels=None,
2460- colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w') ,
2461+ colors=None ,
24612462 autopct=None, pctdistance=0.6, shadow=False,
24622463 labeldistance=1.1, startangle=None, radius=None,
24632464 counterclock=True, wedgeprops=None, textprops=None,
@@ -2477,7 +2478,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
24772478
24782479 *colors*: [ *None* | color sequence ]
24792480 A sequence of matplotlib color args through which the pie chart
2480- will cycle.
2481+ will cycle. If `None`, will use the colors in the currently
2482+ active cycle.
24812483
24822484 *labels*: [ *None* | len(x) sequence of strings ]
24832485 A sequence of strings providing the labels for each wedge
@@ -2566,7 +2568,12 @@ def pie(self, x, explode=None, labels=None, colors=None,
25662568 if len (x ) != len (explode ):
25672569 raise ValueError ("'explode' must be of length 'x'" )
25682570 if colors is None :
2569- colors = ('b' , 'g' , 'r' , 'c' , 'm' , 'y' , 'k' , 'w' )
2571+ get_next_color = self ._get_patches_for_fill .get_next_color
2572+ else :
2573+ color_cycle = itertools .cycle (colors )
2574+
2575+ def get_next_color ():
2576+ return six .next (color_cycle )
25702577
25712578 if radius is None :
25722579 radius = 1
@@ -2602,7 +2609,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
26022609
26032610 w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
26042611 360. * max (theta1 , theta2 ),
2605- facecolor = colors [ i % len ( colors )] ,
2612+ facecolor = get_next_color () ,
26062613 ** wedgeprops )
26072614 slices .append (w )
26082615 self .add_patch (w )
@@ -3022,8 +3029,8 @@ def xywhere(xs, ys, mask):
30223029 l0 , = self .plot (x , y , fmt , label = '_nolegend_' , ** kwargs )
30233030
30243031 if ecolor is None :
3025- if l0 is None and 'color' in self . _get_lines . _prop_keys :
3026- ecolor = next ( self ._get_lines .prop_cycler )[ 'color' ]
3032+ if l0 is None :
3033+ ecolor = self ._get_lines .get_next_color ()
30273034 else :
30283035 ecolor = l0 .get_color ()
30293036
@@ -3844,7 +3851,10 @@ def scatter(self, x, y, s=None, c=None, marker='o', cmap=None, norm=None,
38443851 if facecolors is not None :
38453852 c = facecolors
38463853 else :
3847- c = 'b' # The original default
3854+ if rcParams ['_internal.classic_mode' ]:
3855+ c = 'b' # The original default
3856+ else :
3857+ c = self ._get_patches_for_fill .get_next_color ()
38483858
38493859 if edgecolors is None and not rcParams ['_internal.classic_mode' ]:
38503860 edgecolors = 'face'
@@ -6015,9 +6025,8 @@ def _normalize_input(inp, ename='input'):
60156025 raise ValueError (
60166026 'weights should have the same shape as x' )
60176027
6018- if color is None and 'color' in self ._get_lines ._prop_keys :
6019- color = [next (self ._get_lines .prop_cycler )['color' ]
6020- for i in xrange (nx )]
6028+ if color is None :
6029+ color = [self ._get_lines .get_next_color () for i in xrange (nx )]
60216030 else :
60226031 color = mcolors .colorConverter .to_rgba_array (color )
60236032 if len (color ) != nx :
@@ -7503,6 +7512,12 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
75037512 perp_lines = self .vlines
75047513 par_lines = self .hlines
75057514
7515+ if rcParams ['_internal.classic_mode' ]:
7516+ fillcolor = 'y'
7517+ edgecolor = 'r'
7518+ else :
7519+ fillcolor = edgecolor = self ._get_lines .get_next_color ()
7520+
75067521 # Render violins
75077522 bodies = []
75087523 for stats , pos , width in zip (vpstats , positions , widths ):
@@ -7513,7 +7528,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
75137528 bodies += [fill (stats ['coords' ],
75147529 - vals + pos ,
75157530 vals + pos ,
7516- facecolor = 'y' ,
7531+ facecolor = fillcolor ,
75177532 alpha = 0.3 )]
75187533 means .append (stats ['mean' ])
75197534 mins .append (stats ['min' ])
@@ -7523,20 +7538,24 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
75237538
75247539 # Render means
75257540 if showmeans :
7526- artists ['cmeans' ] = perp_lines (means , pmins , pmaxes , colors = 'r' )
7541+ artists ['cmeans' ] = perp_lines (means , pmins , pmaxes ,
7542+ colors = edgecolor )
75277543
75287544 # Render extrema
75297545 if showextrema :
7530- artists ['cmaxes' ] = perp_lines (maxes , pmins , pmaxes , colors = 'r' )
7531- artists ['cmins' ] = perp_lines (mins , pmins , pmaxes , colors = 'r' )
7532- artists ['cbars' ] = par_lines (positions , mins , maxes , colors = 'r' )
7546+ artists ['cmaxes' ] = perp_lines (maxes , pmins , pmaxes ,
7547+ colors = edgecolor )
7548+ artists ['cmins' ] = perp_lines (mins , pmins , pmaxes ,
7549+ colors = edgecolor )
7550+ artists ['cbars' ] = par_lines (positions , mins , maxes ,
7551+ colors = edgecolor )
75337552
75347553 # Render medians
75357554 if showmedians :
75367555 artists ['cmedians' ] = perp_lines (medians ,
75377556 pmins ,
75387557 pmaxes ,
7539- colors = 'r' )
7558+ colors = edgecolor )
75407559
75417560 return artists
75427561
0 commit comments