From 60beb5be4ea1f1062a08ec191a704b79edc40260 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 9 Sep 2017 12:15:37 -0700 Subject: [PATCH] six.next -> next (available since Py2.6). --- lib/matplotlib/axes/_axes.py | 4 ++-- lib/matplotlib/axes/_base.py | 8 +++----- lib/matplotlib/legend_handler.py | 14 +++++--------- lib/matplotlib/sankey.py | 2 +- lib/matplotlib/stackplot.py | 5 ++--- lib/mpl_toolkits/axisartist/clip_path.py | 2 +- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index f83663273c64..d9f06d6ce3cb 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2631,7 +2631,7 @@ def pie(self, x, explode=None, labels=None, colors=None, color_cycle = itertools.cycle(colors) def get_next_color(): - return six.next(color_cycle) + return next(color_cycle) if radius is None: radius = 1 @@ -2880,7 +2880,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, if 'color' in kwargs: base_style['color'] = kwargs.pop('color') else: - base_style = six.next(self._get_lines.prop_cycler) + base_style = next(self._get_lines.prop_cycler) base_style['label'] = '_nolegend_' base_style.update(fmt_style_kwargs) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index d08f2cdf0907..b693c5f16220 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -197,12 +197,10 @@ def __call__(self, *args, **kwargs): return ret def get_next_color(self): - """ - Return the next color in the cycle. - """ + """Return the next color in the cycle.""" if 'color' not in self._prop_keys: return 'k' - return six.next(self.prop_cycler)['color'] + return next(self.prop_cycler)['color'] def set_lineprops(self, line, **kwargs): assert self.command == 'plot', 'set_lineprops only works with "plot"' @@ -275,7 +273,7 @@ def _getdefaults(self, ignore, *kwargs): for k in prop_keys): # Need to copy this dictionary or else the next time around # in the cycle, the dictionary could be missing entries. - default_dict = six.next(self.prop_cycler).copy() + default_dict = next(self.prop_cycler).copy() for p in ignore: default_dict.pop(p, None) else: diff --git a/lib/matplotlib/legend_handler.py b/lib/matplotlib/legend_handler.py index 9ed73e316b12..f5a48a82b572 100644 --- a/lib/matplotlib/legend_handler.py +++ b/lib/matplotlib/legend_handler.py @@ -664,20 +664,16 @@ def create_artists(self, legend, orig_handle, pad = self._pad * fontsize if ndivide > 1: - width = (width - pad*(ndivide - 1)) / ndivide + width = (width - pad * (ndivide - 1)) / ndivide - xds = [xdescent - (width + pad) * i for i in range(ndivide)] - xds_cycle = cycle(xds) + xds_cycle = cycle(xdescent - (width + pad) * np.arange(ndivide)) a_list = [] for handle1 in orig_handle: handler = legend.get_legend_handler(handler_map, handle1) - _a_list = handler.create_artists(legend, handle1, - six.next(xds_cycle), - ydescent, - width, height, - fontsize, - trans) + _a_list = handler.create_artists( + legend, handle1, + next(xds_cycle), ydescent, width, height, fontsize, trans) a_list.extend(_a_list) return a_list diff --git a/lib/matplotlib/sankey.py b/lib/matplotlib/sankey.py index 84a2c2950faf..749f95212d32 100644 --- a/lib/matplotlib/sankey.py +++ b/lib/matplotlib/sankey.py @@ -748,7 +748,7 @@ def _get_angle(a, r): fc = kwargs.pop('fc', kwargs.pop('facecolor', None)) lw = kwargs.pop('lw', kwargs.pop('linewidth', None)) if fc is None: - fc = six.next(self.ax._get_patches_for_fill.prop_cycler)['color'] + fc = next(self.ax._get_patches_for_fill.prop_cycler)['color'] patch = PathPatch(Path(vertices, codes), fc=fc, lw=lw, **kwargs) self.ax.add_patch(patch) diff --git a/lib/matplotlib/stackplot.py b/lib/matplotlib/stackplot.py index 899e660ae2ae..f7a1c5abaf00 100644 --- a/lib/matplotlib/stackplot.py +++ b/lib/matplotlib/stackplot.py @@ -118,7 +118,7 @@ def stackplot(axes, x, *args, **kwargs): # Color between x = 0 and the first array. color = axes._get_lines.get_next_color() coll = axes.fill_between(x, first_line, stack[0, :], - facecolor=color, label=six.next(labels, None), + facecolor=color, label=next(labels, None), **kwargs) coll.sticky_edges.y[:] = [0] r = [coll] @@ -127,7 +127,6 @@ def stackplot(axes, x, *args, **kwargs): for i in xrange(len(y) - 1): color = axes._get_lines.get_next_color() r.append(axes.fill_between(x, stack[i, :], stack[i + 1, :], - facecolor=color, - label=six.next(labels, None), + facecolor=color, label=next(labels, None), **kwargs)) return r diff --git a/lib/mpl_toolkits/axisartist/clip_path.py b/lib/mpl_toolkits/axisartist/clip_path.py index f81bfb369287..08ea38f7529e 100644 --- a/lib/mpl_toolkits/axisartist/clip_path.py +++ b/lib/mpl_toolkits/axisartist/clip_path.py @@ -156,7 +156,7 @@ def clip_line_to_rect(xline, yline, bbox): ccc = iter(["ro", "go", "rx", "bx"]) for ttt in ticks: - cc = six.next(ccc) + cc = next(ccc) for (xx, yy), aa in ttt: plt.plot([xx], [yy], cc)