Skip to content

Commit

Permalink
Merge pull request matplotlib#1031 from WeatherGod/errorbar_capthick
Browse files Browse the repository at this point in the history
Added 'capthick' kwarg to errorbar()
  • Loading branch information
efiring committed Aug 17, 2012
2 parents 2798e47 + 11767a3 commit d0c501b
Show file tree
Hide file tree
Showing 11 changed files with 3,774 additions and 9 deletions.
7 changes: 7 additions & 0 deletions doc/api/api_changes.rst
Expand Up @@ -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
================

Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/errorbar_demo.py
Expand Up @@ -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')
Expand Down
31 changes: 25 additions & 6 deletions lib/matplotlib/axes.py
Expand Up @@ -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*.
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions lib/matplotlib/pyplot.py
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d0c501b

Please sign in to comment.