Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19c20be

Browse files
committed
Added 'capthick' kwarg to errorbar()
1 parent 1ee7e7b commit 19c20be

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5179,14 +5179,16 @@ def pie(self, x, explode=None, labels=None, colors=None,
51795179
def errorbar(self, x, y, yerr=None, xerr=None,
51805180
fmt='-', ecolor=None, elinewidth=None, capsize=3,
51815181
barsabove=False, lolims=False, uplims=False,
5182-
xlolims=False, xuplims=False, errorevery=1, **kwargs):
5182+
xlolims=False, xuplims=False, errorevery=1, capthick=None,
5183+
**kwargs):
51835184
"""
51845185
Call signature::
51855186
51865187
errorbar(x, y, yerr=None, xerr=None,
51875188
fmt='-', ecolor=None, elinewidth=None, capsize=3,
51885189
barsabove=False, lolims=False, uplims=False,
5189-
xlolims=False, xuplims=False)
5190+
xlolims=False, xuplims=False, errorevery=1,
5191+
capthick=None)
51905192
51915193
Plot *x* versus *y* with error deltas in *yerr* and *xerr*.
51925194
Vertical errorbars are plotted if *yerr* is not *None*.
@@ -5210,14 +5212,22 @@ def errorbar(self, x, y, yerr=None, xerr=None,
52105212
errorbars to a bar plot, for example.
52115213
52125214
*ecolor*: [ *None* | mpl color ]
5213-
a matplotlib color arg which gives the color the errorbar lines;
5215+
A matplotlib color arg which gives the color the errorbar lines;
52145216
if *None*, use the marker color.
52155217
52165218
*elinewidth*: scalar
5217-
the linewidth of the errorbar lines. If *None*, use the linewidth.
5219+
The linewidth of the errorbar lines. If *None*, use the linewidth.
52185220
52195221
*capsize*: scalar
5220-
the size of the error bar caps in points
5222+
The size of the error bar caps in points
5223+
5224+
*capthick*: scalar
5225+
An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This
5226+
setting is a more sensible name for the property that
5227+
controls the thickness of the error bar cap in points. For
5228+
backwards compatibility, if *mew* or *markeredgewidth* are given,
5229+
then they will over-ride *capthick*. This may change in future
5230+
releases.
52215231
52225232
*barsabove*: [ *True* | *False* ]
52235233
if *True*, will plot the errorbars above the plot
@@ -5268,7 +5278,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
52685278
"""
52695279

52705280
if errorevery < 1:
5271-
raise ValueError('errorevery has to be a strictly positive integer ')
5281+
raise ValueError('errorevery has to be a strictly positive integer')
52725282

52735283
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
52745284
if not self._hold: self.cla()
@@ -5344,6 +5354,15 @@ def xywhere(xs, ys, mask):
53445354
plot_kw = {
53455355
'ms':2*capsize,
53465356
'label':'_nolegend_'}
5357+
if capthick is not None:
5358+
# 'mew' has higher priority, I believe,
5359+
# if both 'mew' and 'markeredgewidth' exists.
5360+
# So, save capthick to markeredgewidth so that
5361+
# explicitly setting mew or markeredgewidth will
5362+
# over-write capthick.
5363+
plot_kw['markeredgewidth'] = capthick
5364+
# For backwards-compat, allow explicit setting of
5365+
# 'mew' or 'markeredgewidth' to over-ride capthick.
53475366
if 'markeredgewidth' in kwargs:
53485367
plot_kw['markeredgewidth']=kwargs['markeredgewidth']
53495368
if 'mew' in kwargs:

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,8 @@ def csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
25282528
@autogen_docstring(Axes.errorbar)
25292529
def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
25302530
capsize=3, barsabove=False, lolims=False, uplims=False,
2531-
xlolims=False, xuplims=False, errorevery=1, hold=None, **kwargs):
2531+
xlolims=False, xuplims=False, errorevery=1, capthick=None,
2532+
hold=None, **kwargs):
25322533
ax = gca()
25332534
# allow callers to override the hold state by passing hold=True|False
25342535
washold = ax.ishold()
@@ -2540,7 +2541,7 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
25402541
elinewidth=elinewidth, capsize=capsize,
25412542
barsabove=barsabove, lolims=lolims, uplims=uplims,
25422543
xlolims=xlolims, xuplims=xuplims,
2543-
errorevery=errorevery, **kwargs)
2544+
errorevery=errorevery, capthick=capthick, **kwargs)
25442545
draw_if_interactive()
25452546
finally:
25462547
ax.hold(washold)

0 commit comments

Comments
 (0)