9
9
import math
10
10
from operator import itemgetter
11
11
12
- from cycler import cycler , Cycler
13
12
import numpy as np
14
13
from numpy import ma
15
14
33
32
from matplotlib .offsetbox import OffsetBox
34
33
from matplotlib .artist import allow_rasterization
35
34
from matplotlib .cbook import iterable
35
+ from matplotlib .rcsetup import cycler
36
36
37
37
rcParams = matplotlib .rcParams
38
38
@@ -149,18 +149,20 @@ def __setstate__(self, state):
149
149
self .__dict__ = state .copy ()
150
150
self .set_prop_cycle ()
151
151
152
- def set_prop_cycle (self , prop_cycler = None ):
153
- if prop_cycler is None :
152
+ def set_prop_cycle (self , * args , ** kwargs ):
153
+ if not ( args or kwargs ) or ( len ( args ) == 1 and args [ 0 ] is None ) :
154
154
prop_cycler = rcParams ['axes.prop_cycle' ]
155
155
if prop_cycler is None and 'axes.color_cycle' in rcParams :
156
156
clist = rcParams ['axes.color_cycle' ]
157
157
prop_cycler = cycler ('color' , clist )
158
+ else :
159
+ prop_cycler = cycler (* args , ** kwargs )
160
+
158
161
self .prop_cycler = itertools .cycle (prop_cycler )
159
162
# This should make a copy
160
163
self ._prop_keys = prop_cycler .keys
161
164
162
165
def __call__ (self , * args , ** kwargs ):
163
-
164
166
if self .axes .xaxis is not None and self .axes .yaxis is not None :
165
167
xunits = kwargs .pop ('xunits' , self .axes .xaxis .units )
166
168
@@ -1055,14 +1057,51 @@ def clear(self):
1055
1057
"""clear the axes"""
1056
1058
self .cla ()
1057
1059
1058
- def set_prop_cycle (self , prop_cycle ):
1060
+ def set_prop_cycle (self , * args , ** kwargs ):
1059
1061
"""
1060
1062
Set the property cycle for any future plot commands on this Axes.
1061
1063
1062
- *prop_cycle* is a :class:`Cycler` object.
1063
- Can also be `None` to reset to the cycle defined by the
1064
- current style.
1065
- """
1064
+ set_prop_cycle(arg)
1065
+ set_prop_cycle(label, itr)
1066
+ set_prop_cycle(label1=itr1[, label2=itr2[, ...]])
1067
+
1068
+ Form 1 simply sets given `Cycler` object.
1069
+
1070
+ Form 2 creates and sets a `Cycler` from a label and an iterable.
1071
+
1072
+ Form 3 composes and sets a `Cycler` as an inner product of the
1073
+ pairs of keyword arguments. In other words, all of the
1074
+ iterables are cycled simultaneously, as if through zip().
1075
+
1076
+ Parameters
1077
+ ----------
1078
+ arg : Cycler
1079
+ Set the given Cycler.
1080
+ Can also be `None` to reset to the cycle defined by the
1081
+ current style.
1082
+
1083
+ label : name
1084
+ The property key. Must be a valid `Artist` property.
1085
+ For example, 'color' or 'linestyle'. Aliases are allowed,
1086
+ such as 'c' for 'color' and 'lw' for 'linewidth'.
1087
+
1088
+ itr : iterable
1089
+ Finite-length iterable of the property values. These values
1090
+ are validated and will raise a ValueError if invalid.
1091
+
1092
+ See Also
1093
+ --------
1094
+ :func:`cycler` Convenience function for creating your
1095
+ own cyclers.
1096
+
1097
+ """
1098
+ if args and kwargs :
1099
+ raise TypeError ("Cannot supply both positional and keyword "
1100
+ "arguments to this method." )
1101
+ if len (args ) == 1 and args [0 ] is None :
1102
+ prop_cycle = None
1103
+ else :
1104
+ prop_cycle = cycler (* args , ** kwargs )
1066
1105
self ._get_lines .set_prop_cycle (prop_cycle )
1067
1106
self ._get_patches_for_fill .set_prop_cycle (prop_cycle )
1068
1107
@@ -1076,7 +1115,7 @@ def set_color_cycle(self, clist):
1076
1115
"""
1077
1116
cbook .warn_deprecated (
1078
1117
'1.5' , name = 'set_color_cycle' , alternative = 'set_prop_cycle' )
1079
- self .set_prop_cycle (cycler ( 'color' , clist ) )
1118
+ self .set_prop_cycle ('color' , clist )
1080
1119
1081
1120
def ishold (self ):
1082
1121
"""return the HOLD status of the axes"""
0 commit comments