|
9 | 9 | import math |
10 | 10 | from operator import itemgetter |
11 | 11 |
|
12 | | -from cycler import cycler |
| 12 | +from cycler import cycler, Cycler |
13 | 13 | import numpy as np |
14 | 14 | from numpy import ma |
15 | 15 |
|
@@ -139,25 +139,25 @@ class _process_plot_var_args(object): |
139 | 139 | def __init__(self, axes, command='plot'): |
140 | 140 | self.axes = axes |
141 | 141 | self.command = command |
142 | | - self.set_style_cycle() |
| 142 | + self.set_prop_cycle() |
143 | 143 |
|
144 | 144 | def __getstate__(self): |
145 | 145 | # note: it is not possible to pickle a itertools.cycle instance |
146 | 146 | return {'axes': self.axes, 'command': self.command} |
147 | 147 |
|
148 | 148 | def __setstate__(self, state): |
149 | 149 | self.__dict__ = state.copy() |
150 | | - self.set_style_cycle() |
| 150 | + self.set_prop_cycle() |
151 | 151 |
|
152 | | - def set_style_cycle(self, style_cycler=None): |
153 | | - if style_cycler is None: |
154 | | - style_cycler = rcParams['axes.style_cycle'] |
155 | | - if style_cycler is None and 'axes.color_cycle' in rcParams: |
| 152 | + def set_prop_cycle(self, prop_cycler=None): |
| 153 | + if prop_cycler is None: |
| 154 | + prop_cycler = rcParams['axes.prop_cycle'] |
| 155 | + if prop_cycler is None and 'axes.color_cycle' in rcParams: |
156 | 156 | clist = rcParams['axes.color_cycle'] |
157 | | - style_cycler = cycler('color', clist) |
158 | | - self.style_cycler = itertools.cycle(style_cycler) |
| 157 | + prop_cycler = cycler('color', clist) |
| 158 | + self.prop_cycler = itertools.cycle(prop_cycler) |
159 | 159 | # Make a copy |
160 | | - self._style_keys = list(style_cycler.keys) |
| 160 | + self._prop_keys = list(prop_cycler.keys) |
161 | 161 |
|
162 | 162 | def __call__(self, *args, **kwargs): |
163 | 163 |
|
@@ -240,12 +240,12 @@ def _setdefaults(self, kw, kwargs): |
240 | 240 | # has information that is not specified |
241 | 241 | # in the supplied kw and kwargs dicts |
242 | 242 | if any([kw.get(k, None) is None and kwargs.get(k, None) is None |
243 | | - for k in self._style_keys]): |
244 | | - default_dict = six.next(self.style_cycler) |
| 243 | + for k in self._prop_keys]): |
| 244 | + default_dict = six.next(self.prop_cycler) |
245 | 245 | else: |
246 | 246 | default_dict = None |
247 | 247 |
|
248 | | - for k in self._style_keys: |
| 248 | + for k in self._prop_keys: |
249 | 249 | if (default_dict is not None and |
250 | 250 | kw.get(k, None) is None and |
251 | 251 | kwargs.get(k, None) is None): |
@@ -1004,14 +1004,30 @@ def clear(self): |
1004 | 1004 | """clear the axes""" |
1005 | 1005 | self.cla() |
1006 | 1006 |
|
| 1007 | + def set_prop_cycle(self, prop_cycle): |
| 1008 | + """ |
| 1009 | + Set the prop cycle for any future plot commands on this Axes. |
| 1010 | +
|
| 1011 | + *prop_cycle* is a :class:Cycler object. |
| 1012 | + Can also be `None` to reset to the cycle defined by the |
| 1013 | + current style. |
| 1014 | + """ |
| 1015 | + self._get_lines.set_prop_cycle(prop_cycle) |
| 1016 | + self._get_patches_for_fill.set_prop_cycle(prop_cycle) |
| 1017 | + |
1007 | 1018 | def set_color_cycle(self, clist): |
1008 | 1019 | """ |
1009 | 1020 | Set the color cycle for any future plot commands on this Axes. |
1010 | 1021 |
|
1011 | 1022 | *clist* is a list of mpl color specifiers. |
| 1023 | +
|
| 1024 | + .. deprecated:: 1.5 |
1012 | 1025 | """ |
1013 | | - self._get_lines.set_color_cycle(clist) |
1014 | | - self._get_patches_for_fill.set_color_cycle(clist) |
| 1026 | + cbook.warn_deprecated( |
| 1027 | + '1.5', name='set_color_cycle', alternative='set_prop_cycle') |
| 1028 | + prop_cycler = cycler('color', clist) |
| 1029 | + self._get_lines.set_prop_cycle(prop_cycler) |
| 1030 | + self._get_patches_for_fill.set_prop_cycle(prop_cycler) |
1015 | 1031 |
|
1016 | 1032 | def ishold(self): |
1017 | 1033 | """return the HOLD status of the axes""" |
|
0 commit comments