4
4
from matplotlib .externals import six
5
5
from matplotlib .externals .six .moves import reduce , xrange , zip , zip_longest
6
6
7
+ import itertools
7
8
import math
8
9
import warnings
9
10
@@ -2457,7 +2458,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
2457
2458
Call signature::
2458
2459
2459
2460
pie(x, explode=None, labels=None,
2460
- colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w') ,
2461
+ colors=None ,
2461
2462
autopct=None, pctdistance=0.6, shadow=False,
2462
2463
labeldistance=1.1, startangle=None, radius=None,
2463
2464
counterclock=True, wedgeprops=None, textprops=None,
@@ -2477,7 +2478,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
2477
2478
2478
2479
*colors*: [ *None* | color sequence ]
2479
2480
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.
2481
2483
2482
2484
*labels*: [ *None* | len(x) sequence of strings ]
2483
2485
A sequence of strings providing the labels for each wedge
@@ -2566,7 +2568,12 @@ def pie(self, x, explode=None, labels=None, colors=None,
2566
2568
if len (x ) != len (explode ):
2567
2569
raise ValueError ("'explode' must be of length 'x'" )
2568
2570
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 )
2570
2577
2571
2578
if radius is None :
2572
2579
radius = 1
@@ -2602,7 +2609,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
2602
2609
2603
2610
w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
2604
2611
360. * max (theta1 , theta2 ),
2605
- facecolor = colors [ i % len ( colors )] ,
2612
+ facecolor = get_next_color () ,
2606
2613
** wedgeprops )
2607
2614
slices .append (w )
2608
2615
self .add_patch (w )
@@ -3022,8 +3029,8 @@ def xywhere(xs, ys, mask):
3022
3029
l0 , = self .plot (x , y , fmt , label = '_nolegend_' , ** kwargs )
3023
3030
3024
3031
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 ()
3027
3034
else :
3028
3035
ecolor = l0 .get_color ()
3029
3036
@@ -3844,7 +3851,10 @@ def scatter(self, x, y, s=None, c=None, marker='o', cmap=None, norm=None,
3844
3851
if facecolors is not None :
3845
3852
c = facecolors
3846
3853
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 ()
3848
3858
3849
3859
if edgecolors is None and not rcParams ['_internal.classic_mode' ]:
3850
3860
edgecolors = 'face'
@@ -6015,9 +6025,8 @@ def _normalize_input(inp, ename='input'):
6015
6025
raise ValueError (
6016
6026
'weights should have the same shape as x' )
6017
6027
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 )]
6021
6030
else :
6022
6031
color = mcolors .colorConverter .to_rgba_array (color )
6023
6032
if len (color ) != nx :
@@ -7503,6 +7512,12 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
7503
7512
perp_lines = self .vlines
7504
7513
par_lines = self .hlines
7505
7514
7515
+ if rcParams ['_internal.classic_mode' ]:
7516
+ fillcolor = 'y'
7517
+ edgecolor = 'r'
7518
+ else :
7519
+ fillcolor = edgecolor = self ._get_lines .get_next_color ()
7520
+
7506
7521
# Render violins
7507
7522
bodies = []
7508
7523
for stats , pos , width in zip (vpstats , positions , widths ):
@@ -7513,7 +7528,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
7513
7528
bodies += [fill (stats ['coords' ],
7514
7529
- vals + pos ,
7515
7530
vals + pos ,
7516
- facecolor = 'y' ,
7531
+ facecolor = fillcolor ,
7517
7532
alpha = 0.3 )]
7518
7533
means .append (stats ['mean' ])
7519
7534
mins .append (stats ['min' ])
@@ -7523,20 +7538,24 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
7523
7538
7524
7539
# Render means
7525
7540
if showmeans :
7526
- artists ['cmeans' ] = perp_lines (means , pmins , pmaxes , colors = 'r' )
7541
+ artists ['cmeans' ] = perp_lines (means , pmins , pmaxes ,
7542
+ colors = edgecolor )
7527
7543
7528
7544
# Render extrema
7529
7545
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 )
7533
7552
7534
7553
# Render medians
7535
7554
if showmedians :
7536
7555
artists ['cmedians' ] = perp_lines (medians ,
7537
7556
pmins ,
7538
7557
pmaxes ,
7539
- colors = 'r' )
7558
+ colors = edgecolor )
7540
7559
7541
7560
return artists
7542
7561
0 commit comments