Permalink
Browse files

Merge pull request #1031 from WeatherGod/errorbar_capthick

Added 'capthick' kwarg to errorbar()
  • Loading branch information...
2 parents 2798e47 + 11767a3 commit d0c501b3d13bdcc256593f3251cf026419908d58 @efiring efiring committed Aug 17, 2012
View
@@ -65,6 +65,13 @@ Changes in 1.2.x
:class:`~matplotlib.colorbar.ColorbarBase` allows one to control the size of
the triangular minimum and maximum extensions on colorbars.
+* A new keyword *capthick* in :meth:`~matplotlib.pyplot.errorbar` has been
+ added as an intuitive alias to the *markeredgewidth* and *mew* keyword
+ arguments, which indirectly controlled the thickness of the caps on
+ the errorbars. For backwards compatibility, specifying either of the
+ original keyword arguments will override any value provided by
+ *capthick*.
+
Changes in 1.1.x
================
@@ -39,7 +39,7 @@
yerr_lower = y - ylower
ax.errorbar(x, y, yerr=[yerr_lower, 2*yerr], xerr=xerr,
- fmt='o', ecolor='g')
+ fmt='o', ecolor='g', capthick=2)
ax.set_title('Mixed sym., log y')
fig.suptitle('Variable errorbars')
View
@@ -5179,14 +5179,16 @@ def pie(self, x, explode=None, labels=None, colors=None,
def errorbar(self, x, y, yerr=None, xerr=None,
fmt='-', ecolor=None, elinewidth=None, capsize=3,
barsabove=False, lolims=False, uplims=False,
- xlolims=False, xuplims=False, errorevery=1, **kwargs):
+ xlolims=False, xuplims=False, errorevery=1, capthick=None,
+ **kwargs):
"""
Call signature::
errorbar(x, y, yerr=None, xerr=None,
fmt='-', ecolor=None, elinewidth=None, capsize=3,
barsabove=False, lolims=False, uplims=False,
- xlolims=False, xuplims=False)
+ xlolims=False, xuplims=False, errorevery=1,
+ capthick=None)
Plot *x* versus *y* with error deltas in *yerr* and *xerr*.
Vertical errorbars are plotted if *yerr* is not *None*.
@@ -5210,14 +5212,22 @@ def errorbar(self, x, y, yerr=None, xerr=None,
errorbars to a bar plot, for example.
*ecolor*: [ *None* | mpl color ]
- a matplotlib color arg which gives the color the errorbar lines;
+ A matplotlib color arg which gives the color the errorbar lines;
if *None*, use the marker color.
*elinewidth*: scalar
- the linewidth of the errorbar lines. If *None*, use the linewidth.
+ The linewidth of the errorbar lines. If *None*, use the linewidth.
*capsize*: scalar
- the size of the error bar caps in points
+ The length of the error bar caps in points
+
+ *capthick*: scalar
+ An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This
+ setting is a more sensible name for the property that
+ controls the thickness of the error bar cap in points. For
+ backwards compatibility, if *mew* or *markeredgewidth* are given,
+ then they will over-ride *capthick*. This may change in future
+ releases.
*barsabove*: [ *True* | *False* ]
if *True*, will plot the errorbars above the plot
@@ -5268,7 +5278,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
"""
if errorevery < 1:
- raise ValueError('errorevery has to be a strictly positive integer ')
+ raise ValueError('errorevery has to be a strictly positive integer')
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
if not self._hold: self.cla()
@@ -5344,6 +5354,15 @@ def xywhere(xs, ys, mask):
plot_kw = {
'ms':2*capsize,
'label':'_nolegend_'}
+ 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.
if 'markeredgewidth' in kwargs:
plot_kw['markeredgewidth']=kwargs['markeredgewidth']
if 'mew' in kwargs:
View
@@ -2533,7 +2533,8 @@ def csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
@autogen_docstring(Axes.errorbar)
def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
capsize=3, barsabove=False, lolims=False, uplims=False,
- xlolims=False, xuplims=False, errorevery=1, hold=None, **kwargs):
+ xlolims=False, xuplims=False, errorevery=1, capthick=None,
+ hold=None, **kwargs):
ax = gca()
# allow callers to override the hold state by passing hold=True|False
washold = ax.ishold()
@@ -2545,7 +2546,7 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
elinewidth=elinewidth, capsize=capsize,
barsabove=barsabove, lolims=lolims, uplims=uplims,
xlolims=xlolims, xuplims=xuplims,
- errorevery=errorevery, **kwargs)
+ errorevery=errorevery, capthick=capthick, **kwargs)
draw_if_interactive()
finally:
ax.hold(washold)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit d0c501b

Please sign in to comment.