From c8a365a383880d4b4c87208139490297cead741c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 18 Nov 2015 22:18:12 -0500 Subject: [PATCH 1/7] MNT: start to use artists directly in errorbar Instead of using calls to `plt.plot` --- lib/matplotlib/axes/_axes.py | 127 ++++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 57c138f9e300..c658cd4ee013 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2806,15 +2806,32 @@ def errorbar(self, x, y, yerr=None, xerr=None, if fmt is None: fmt = 'none' - msg = ('Use of None object as fmt keyword argument to ' - + 'suppress plotting of data values is deprecated ' - + 'since 1.4; use the string "none" instead.') + msg = ('Use of None object as fmt keyword argument to ' + + 'suppress plotting of data values is deprecated ' + + 'since 1.4; use the string "none" instead.') warnings.warn(msg, mplDeprecation, stacklevel=1) plot_line = (fmt.lower() != 'none') - label = kwargs.pop("label", None) + fmt_style_kwargs = {k: v for k, v in + zip(('linestyle', 'marker', 'color'), + _process_plot_format(fmt)) if v is not None} + + if ('color' in kwargs or 'color' in fmt_style_kwargs or + ecolor is not None): + base_style = {} + if 'color' in kwargs: + base_style['color'] = kwargs.pop('color') + else: + base_style = six.next(self._get_lines.prop_cycler) + + base_style['label'] = '_nolegend_' + base_style.update(fmt_style_kwargs) + if 'color' not in base_style: + base_style['color'] = 'b' + if ecolor is None: + ecolor = base_style['color'] # make sure all the args are iterable; use lists not arrays to # preserve units if not iterable(x): @@ -2836,12 +2853,18 @@ def errorbar(self, x, y, yerr=None, xerr=None, # Instead of using zorder, the line plot is being added # either here, or after all the errorbar plot elements. if barsabove and plot_line: - l0, = self.plot(x, y, fmt, label="_nolegend_", **kwargs) + # in python3.5+ this can be simplified + eb_style = dict(base_style) + eb_style.update(**kwargs) + l0 = mlines.Line2D(x, y, **eb_style) + self.add_line(l0) barcols = [] caplines = [] - lines_kw = {'label': '_nolegend_'} + lines_kw = dict(base_style) + lines_kw.pop('marker', None) + lines_kw.pop('linestyle', None) if elinewidth: lines_kw['linewidth'] = elinewidth else: @@ -2853,25 +2876,16 @@ def errorbar(self, x, y, yerr=None, xerr=None, lines_kw[key] = kwargs[key] # arrays fine here, they are booleans and hence not units - if not iterable(lolims): - lolims = np.asarray([lolims] * len(x), bool) - else: - lolims = np.asarray(lolims, bool) - - if not iterable(uplims): - uplims = np.array([uplims] * len(x), bool) - else: - uplims = np.asarray(uplims, bool) - - if not iterable(xlolims): - xlolims = np.array([xlolims] * len(x), bool) - else: - xlolims = np.asarray(xlolims, bool) + def _bool_asarray_helper(d, expected): + if not iterable(d): + return np.asarray([d] * expected, bool) + else: + return np.asarray(d, bool) - if not iterable(xuplims): - xuplims = np.array([xuplims] * len(x), bool) - else: - xuplims = np.asarray(xuplims, bool) + lolims = _bool_asarray_helper(lolims, len(x)) + uplims = _bool_asarray_helper(uplims, len(x)) + xlolims = _bool_asarray_helper(xlolims, len(x)) + xuplims = _bool_asarray_helper(xuplims, len(x)) everymask = np.arange(len(x)) % errorevery == 0 @@ -2886,7 +2900,11 @@ def xywhere(xs, ys, mask): ys = [thisy for thisy, b in zip(ys, mask) if b] return xs, ys - plot_kw = {'label': '_nolegend_'} + plot_kw = dict(base_style) + # eject any marker information from format string + plot_kw.pop('marker', None) + plot_kw.pop('ls', None) + plot_kw['linestyle'] = 'none' if capsize is None: capsize = rcParams["errorbar.capsize"] if capsize > 0: @@ -2904,6 +2922,7 @@ def xywhere(xs, ys, mask): 'zorder', 'rasterized'): if key in kwargs: plot_kw[key] = kwargs[key] + plot_kw['color'] = ecolor def extract_err(err, data): '''private function to compute error bars @@ -2951,8 +2970,10 @@ def extract_err(err, data): lo, ro = xywhere(left, right, noxlims & everymask) barcols.append(self.hlines(yo, lo, ro, **lines_kw)) if capsize > 0: - caplines.extend(self.plot(lo, yo, 'k|', **plot_kw)) - caplines.extend(self.plot(ro, yo, 'k|', **plot_kw)) + caplines.append(mlines.Line2D(lo, yo, marker='|', + **plot_kw)) + caplines.append(mlines.Line2D(ro, yo, marker='|', + **plot_kw)) if xlolims.any(): yo, _ = xywhere(y, right, xlolims & everymask) @@ -2963,12 +2984,13 @@ def extract_err(err, data): marker = mlines.CARETLEFTBASE else: marker = mlines.CARETRIGHTBASE - caplines.extend( - self.plot(rightup, yup, ls='None', marker=marker, - **plot_kw)) + caplines.append( + mlines.Line2D(rightup, yup, ls='None', marker=marker, + **plot_kw)) if capsize > 0: xlo, ylo = xywhere(x, y, xlolims & everymask) - caplines.extend(self.plot(xlo, ylo, 'k|', **plot_kw)) + caplines.append(mlines.Line2D(xlo, ylo, marker='|', + **plot_kw)) if xuplims.any(): yo, _ = xywhere(y, right, xuplims & everymask) @@ -2979,12 +3001,13 @@ def extract_err(err, data): marker = mlines.CARETRIGHTBASE else: marker = mlines.CARETLEFTBASE - caplines.extend( - self.plot(leftlo, ylo, ls='None', marker=marker, - **plot_kw)) + caplines.append( + mlines.Line2D(leftlo, ylo, ls='None', marker=marker, + **plot_kw)) if capsize > 0: xup, yup = xywhere(x, y, xuplims & everymask) - caplines.extend(self.plot(xup, yup, 'k|', **plot_kw)) + caplines.append(mlines.Line2D(xup, yup, marker='|', + **plot_kw)) if yerr is not None: lower, upper = extract_err(yerr, y) @@ -2996,8 +3019,10 @@ def extract_err(err, data): lo, uo = xywhere(lower, upper, noylims & everymask) barcols.append(self.vlines(xo, lo, uo, **lines_kw)) if capsize > 0: - caplines.extend(self.plot(xo, lo, 'k_', **plot_kw)) - caplines.extend(self.plot(xo, uo, 'k_', **plot_kw)) + caplines.append(mlines.Line2D(xo, lo, marker='_', + **plot_kw)) + caplines.append(mlines.Line2D(xo, uo, marker='_', + **plot_kw)) if lolims.any(): xo, _ = xywhere(x, lower, lolims & everymask) @@ -3008,12 +3033,13 @@ def extract_err(err, data): marker = mlines.CARETDOWNBASE else: marker = mlines.CARETUPBASE - caplines.extend( - self.plot(xup, upperup, ls='None', marker=marker, - **plot_kw)) + caplines.append( + mlines.Line2D(xup, upperup, ls='None', marker=marker, + **plot_kw)) if capsize > 0: xlo, ylo = xywhere(x, y, lolims & everymask) - caplines.extend(self.plot(xlo, ylo, 'k_', **plot_kw)) + caplines.append(mlines.Line2D(xlo, ylo, marker='_', + **plot_kw)) if uplims.any(): xo, _ = xywhere(x, lower, uplims & everymask) @@ -3024,15 +3050,22 @@ def extract_err(err, data): marker = mlines.CARETUPBASE else: marker = mlines.CARETDOWNBASE - caplines.extend( - self.plot(xlo, lowerlo, ls='None', marker=marker, - **plot_kw)) + caplines.append( + mlines.Line2D(xlo, lowerlo, ls='None', marker=marker, + **plot_kw)) if capsize > 0: xup, yup = xywhere(x, y, uplims & everymask) - caplines.extend(self.plot(xup, yup, 'k_', **plot_kw)) + caplines.append(mlines.Line2D(xup, yup, marker='_', + **plot_kw)) + for l in caplines: + self.add_line(l) if not barsabove and plot_line: - l0, = self.plot(x, y, fmt, label='_nolegend_', **kwargs) + # in python3.5+ this can be simplified + eb_style = dict(base_style) + eb_style.update(**kwargs) + l0 = mlines.Line2D(x, y, **eb_style) + self.add_line(l0) if ecolor is None: if l0 is None: @@ -3042,8 +3075,6 @@ def extract_err(err, data): for l in barcols: l.set_color(ecolor) - for l in caplines: - l.set_color(ecolor) self.autoscale_view() self._hold = holdstate From 9acfc5f0bdc40516a68491917fe6f1595fc0a66f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 12 May 2016 22:38:03 -0400 Subject: [PATCH 2/7] MNT: rename styles dictionaries Need 3 internal style dictionaries: - eb_lines_style : used for the line collections - eb_cap_style : base style to be used for the bar 'caps' - plot_line_style : used from the 'main' line --- lib/matplotlib/axes/_axes.py | 107 +++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index c658cd4ee013..b3443e8dd0e4 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2858,22 +2858,53 @@ def errorbar(self, x, y, yerr=None, xerr=None, eb_style.update(**kwargs) l0 = mlines.Line2D(x, y, **eb_style) self.add_line(l0) + # make the style dict for the 'normal' plot line + plot_line_style = dict(base_style) + plot_line_style.update(**kwargs) - barcols = [] - caplines = [] + # make the style dict for the line collections (the bars) + eb_lines_style = dict(base_style) + eb_lines_style.pop('marker', None) + eb_lines_style.pop('linestyle', None) + eb_lines_style['color'] = ecolor - lines_kw = dict(base_style) - lines_kw.pop('marker', None) - lines_kw.pop('linestyle', None) if elinewidth: - lines_kw['linewidth'] = elinewidth + eb_lines_style['linewidth'] = elinewidth else: for key in ('linewidth', 'lw'): if key in kwargs: - lines_kw[key] = kwargs[key] + eb_lines_style[key] = kwargs[key] for key in ('transform', 'alpha', 'zorder', 'rasterized'): if key in kwargs: - lines_kw[key] = kwargs[key] + eb_lines_style[key] = kwargs[key] + + # set up cap style dictionary + eb_cap_style = dict(base_style) + # eject any marker information from format string + eb_cap_style.pop('marker', None) + eb_cap_style.pop('ls', None) + eb_cap_style['linestyle'] = 'none' + if capsize is None: + capsize = rcParams["errorbar.capsize"] + if capsize > 0: + eb_cap_style['ms'] = 2. * capsize + if capthick is not None: + # 'mew' has higher priority, I believe, + # if both 'mew' and 'markeredgewidth' exists. + # So, save capthick to markeredgewidth so that + # explicitly setting mew or markeredgewidth will + # over-write capthick. + eb_cap_style['markeredgewidth'] = capthick + # For backwards-compat, allow explicit setting of + # 'mew' or 'markeredgewidth' to over-ride capthick. + for key in ('markeredgewidth', 'mew', 'transform', 'alpha', + 'zorder', 'rasterized'): + if key in kwargs: + eb_cap_style[key] = kwargs[key] + eb_cap_style['color'] = ecolor + + barcols = [] + caplines = [] # arrays fine here, they are booleans and hence not units def _bool_asarray_helper(d, expected): @@ -2900,30 +2931,6 @@ def xywhere(xs, ys, mask): ys = [thisy for thisy, b in zip(ys, mask) if b] return xs, ys - plot_kw = dict(base_style) - # eject any marker information from format string - plot_kw.pop('marker', None) - plot_kw.pop('ls', None) - plot_kw['linestyle'] = 'none' - if capsize is None: - capsize = rcParams["errorbar.capsize"] - if capsize > 0: - plot_kw['ms'] = 2. * capsize - if capthick is not None: - # 'mew' has higher priority, I believe, - # if both 'mew' and 'markeredgewidth' exists. - # So, save capthick to markeredgewidth so that - # explicitly setting mew or markeredgewidth will - # over-write capthick. - plot_kw['markeredgewidth'] = capthick - # For backwards-compat, allow explicit setting of - # 'mew' or 'markeredgewidth' to over-ride capthick. - for key in ('markeredgewidth', 'mew', 'transform', 'alpha', - 'zorder', 'rasterized'): - if key in kwargs: - plot_kw[key] = kwargs[key] - plot_kw['color'] = ecolor - def extract_err(err, data): '''private function to compute error bars @@ -2968,17 +2975,17 @@ def extract_err(err, data): if noxlims.any(): yo, _ = xywhere(y, right, noxlims & everymask) lo, ro = xywhere(left, right, noxlims & everymask) - barcols.append(self.hlines(yo, lo, ro, **lines_kw)) + barcols.append(self.hlines(yo, lo, ro, **eb_lines_style)) if capsize > 0: caplines.append(mlines.Line2D(lo, yo, marker='|', - **plot_kw)) + **eb_cap_style)) caplines.append(mlines.Line2D(ro, yo, marker='|', - **plot_kw)) + **eb_cap_style)) if xlolims.any(): yo, _ = xywhere(y, right, xlolims & everymask) lo, ro = xywhere(x, right, xlolims & everymask) - barcols.append(self.hlines(yo, lo, ro, **lines_kw)) + barcols.append(self.hlines(yo, lo, ro, **eb_lines_style)) rightup, yup = xywhere(right, y, xlolims & everymask) if self.xaxis_inverted(): marker = mlines.CARETLEFTBASE @@ -2986,16 +2993,16 @@ def extract_err(err, data): marker = mlines.CARETRIGHTBASE caplines.append( mlines.Line2D(rightup, yup, ls='None', marker=marker, - **plot_kw)) + **eb_cap_style)) if capsize > 0: xlo, ylo = xywhere(x, y, xlolims & everymask) caplines.append(mlines.Line2D(xlo, ylo, marker='|', - **plot_kw)) + **eb_cap_style)) if xuplims.any(): yo, _ = xywhere(y, right, xuplims & everymask) lo, ro = xywhere(left, x, xuplims & everymask) - barcols.append(self.hlines(yo, lo, ro, **lines_kw)) + barcols.append(self.hlines(yo, lo, ro, **eb_lines_style)) leftlo, ylo = xywhere(left, y, xuplims & everymask) if self.xaxis_inverted(): marker = mlines.CARETRIGHTBASE @@ -3003,11 +3010,11 @@ def extract_err(err, data): marker = mlines.CARETLEFTBASE caplines.append( mlines.Line2D(leftlo, ylo, ls='None', marker=marker, - **plot_kw)) + **eb_cap_style)) if capsize > 0: xup, yup = xywhere(x, y, xuplims & everymask) caplines.append(mlines.Line2D(xup, yup, marker='|', - **plot_kw)) + **eb_cap_style)) if yerr is not None: lower, upper = extract_err(yerr, y) @@ -3017,17 +3024,17 @@ def extract_err(err, data): if noylims.any(): xo, _ = xywhere(x, lower, noylims & everymask) lo, uo = xywhere(lower, upper, noylims & everymask) - barcols.append(self.vlines(xo, lo, uo, **lines_kw)) + barcols.append(self.vlines(xo, lo, uo, **eb_lines_style)) if capsize > 0: caplines.append(mlines.Line2D(xo, lo, marker='_', - **plot_kw)) + **eb_cap_style)) caplines.append(mlines.Line2D(xo, uo, marker='_', - **plot_kw)) + **eb_cap_style)) if lolims.any(): xo, _ = xywhere(x, lower, lolims & everymask) lo, uo = xywhere(y, upper, lolims & everymask) - barcols.append(self.vlines(xo, lo, uo, **lines_kw)) + barcols.append(self.vlines(xo, lo, uo, **eb_lines_style)) xup, upperup = xywhere(x, upper, lolims & everymask) if self.yaxis_inverted(): marker = mlines.CARETDOWNBASE @@ -3035,16 +3042,16 @@ def extract_err(err, data): marker = mlines.CARETUPBASE caplines.append( mlines.Line2D(xup, upperup, ls='None', marker=marker, - **plot_kw)) + **eb_cap_style)) if capsize > 0: xlo, ylo = xywhere(x, y, lolims & everymask) caplines.append(mlines.Line2D(xlo, ylo, marker='_', - **plot_kw)) + **eb_cap_style)) if uplims.any(): xo, _ = xywhere(x, lower, uplims & everymask) lo, uo = xywhere(lower, y, uplims & everymask) - barcols.append(self.vlines(xo, lo, uo, **lines_kw)) + barcols.append(self.vlines(xo, lo, uo, **eb_lines_style)) xlo, lowerlo = xywhere(x, lower, uplims & everymask) if self.yaxis_inverted(): marker = mlines.CARETUPBASE @@ -3052,11 +3059,11 @@ def extract_err(err, data): marker = mlines.CARETDOWNBASE caplines.append( mlines.Line2D(xlo, lowerlo, ls='None', marker=marker, - **plot_kw)) + **eb_cap_style)) if capsize > 0: xup, yup = xywhere(x, y, uplims & everymask) caplines.append(mlines.Line2D(xup, yup, marker='_', - **plot_kw)) + **eb_cap_style)) for l in caplines: self.add_line(l) From 06e55e65529712d3e56ff14e47498915e44de311 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 12 May 2016 23:00:35 -0400 Subject: [PATCH 3/7] MNT: remove unneeded re-setting of colors --- lib/matplotlib/axes/_axes.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index b3443e8dd0e4..037f4ac01eab 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3074,15 +3074,6 @@ def extract_err(err, data): l0 = mlines.Line2D(x, y, **eb_style) self.add_line(l0) - if ecolor is None: - if l0 is None: - ecolor = self._get_lines.get_next_color() - else: - ecolor = l0.get_color() - - for l in barcols: - l.set_color(ecolor) - self.autoscale_view() self._hold = holdstate From d6881f08939727d7002cf618b7286f599a42801c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 12 May 2016 23:00:10 -0400 Subject: [PATCH 4/7] MNT: use zorder for barsabove --- lib/matplotlib/axes/_axes.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 037f4ac01eab..9389b9e9ab9a 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2793,6 +2793,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, .. plot:: mpl_examples/statistics/errorbar_demo.py """ + kwargs.setdefault('zorder', 2) if errorevery < 1: raise ValueError( @@ -2850,17 +2851,13 @@ def errorbar(self, x, y, yerr=None, xerr=None, l0 = None - # Instead of using zorder, the line plot is being added - # either here, or after all the errorbar plot elements. - if barsabove and plot_line: - # in python3.5+ this can be simplified - eb_style = dict(base_style) - eb_style.update(**kwargs) - l0 = mlines.Line2D(x, y, **eb_style) - self.add_line(l0) # make the style dict for the 'normal' plot line plot_line_style = dict(base_style) plot_line_style.update(**kwargs) + if barsabove: + plot_line_style['zorder'] = kwargs['zorder'] - .1 + else: + plot_line_style['zorder'] = kwargs['zorder'] + .1 # make the style dict for the line collections (the bars) eb_lines_style = dict(base_style) @@ -2903,6 +2900,10 @@ def errorbar(self, x, y, yerr=None, xerr=None, eb_cap_style[key] = kwargs[key] eb_cap_style['color'] = ecolor + if plot_line: + l0 = mlines.Line2D(x, y, **plot_line_style) + self.add_line(l0) + barcols = [] caplines = [] @@ -3067,12 +3068,6 @@ def extract_err(err, data): for l in caplines: self.add_line(l) - if not barsabove and plot_line: - # in python3.5+ this can be simplified - eb_style = dict(base_style) - eb_style.update(**kwargs) - l0 = mlines.Line2D(x, y, **eb_style) - self.add_line(l0) self.autoscale_view() self._hold = holdstate From e6e48bd7491c2f7d3d4f8cc6e9411911a1269809 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 12 May 2016 23:07:56 -0400 Subject: [PATCH 5/7] MNT: remove alaises --- lib/matplotlib/axes/_axes.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9389b9e9ab9a..f23198ba9dd9 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2793,6 +2793,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, .. plot:: mpl_examples/statistics/errorbar_demo.py """ + kwargs = cbook.normalize_kwargs(kwargs, _alias_map) kwargs.setdefault('zorder', 2) if errorevery < 1: @@ -2830,7 +2831,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, base_style['label'] = '_nolegend_' base_style.update(fmt_style_kwargs) if 'color' not in base_style: - base_style['color'] = 'b' + base_style['color'] = 'C0' if ecolor is None: ecolor = base_style['color'] # make sure all the args are iterable; use lists not arrays to @@ -2867,10 +2868,9 @@ def errorbar(self, x, y, yerr=None, xerr=None, if elinewidth: eb_lines_style['linewidth'] = elinewidth - else: - for key in ('linewidth', 'lw'): - if key in kwargs: - eb_lines_style[key] = kwargs[key] + elif 'linewidth' in kwargs: + eb_lines_style['linewidth'] = kwargs['linewidth'] + for key in ('transform', 'alpha', 'zorder', 'rasterized'): if key in kwargs: eb_lines_style[key] = kwargs[key] @@ -2884,17 +2884,13 @@ def errorbar(self, x, y, yerr=None, xerr=None, if capsize is None: capsize = rcParams["errorbar.capsize"] if capsize > 0: - eb_cap_style['ms'] = 2. * capsize + eb_cap_style['markersize'] = 2. * capsize if capthick is not None: - # 'mew' has higher priority, I believe, - # if both 'mew' and 'markeredgewidth' exists. - # So, save capthick to markeredgewidth so that - # explicitly setting mew or markeredgewidth will - # over-write capthick. eb_cap_style['markeredgewidth'] = capthick + # For backwards-compat, allow explicit setting of - # 'mew' or 'markeredgewidth' to over-ride capthick. - for key in ('markeredgewidth', 'mew', 'transform', 'alpha', + # 'markeredgewidth' to over-ride capthick. + for key in ('markeredgewidth', 'transform', 'alpha', 'zorder', 'rasterized'): if key in kwargs: eb_cap_style[key] = kwargs[key] From 6b176100cf651f9d1ed084f532571ea61147cad7 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 12 May 2016 23:17:03 -0400 Subject: [PATCH 6/7] PEP8 --- lib/matplotlib/axes/_axes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index f23198ba9dd9..2e7c50ee4729 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3064,7 +3064,6 @@ def extract_err(err, data): for l in caplines: self.add_line(l) - self.autoscale_view() self._hold = holdstate From 2338e2e17a049973089841969e73671048f482a2 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 28 May 2016 16:18:06 -0400 Subject: [PATCH 7/7] MNT: remove misleading variable name 'l0' (el-zero) looks too much like 10 (ten) to be used as a variable name. --- lib/matplotlib/axes/_axes.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 2e7c50ee4729..1a5944152223 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2850,8 +2850,6 @@ def errorbar(self, x, y, yerr=None, xerr=None, if not iterable(yerr): yerr = [yerr] * len(y) - l0 = None - # make the style dict for the 'normal' plot line plot_line_style = dict(base_style) plot_line_style.update(**kwargs) @@ -2896,9 +2894,10 @@ def errorbar(self, x, y, yerr=None, xerr=None, eb_cap_style[key] = kwargs[key] eb_cap_style['color'] = ecolor + data_line = None if plot_line: - l0 = mlines.Line2D(x, y, **plot_line_style) - self.add_line(l0) + data_line = mlines.Line2D(x, y, **plot_line_style) + self.add_line(data_line) barcols = [] caplines = [] @@ -3067,7 +3066,7 @@ def extract_err(err, data): self.autoscale_view() self._hold = holdstate - errorbar_container = ErrorbarContainer((l0, tuple(caplines), + errorbar_container = ErrorbarContainer((data_line, tuple(caplines), tuple(barcols)), has_xerr=(xerr is not None), has_yerr=(yerr is not None),