Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0c501b

Browse filesBrowse files
committed
Merge pull request #1031 from WeatherGod/errorbar_capthick
Added 'capthick' kwarg to errorbar()
2 parents 2798e47 + 11767a3 commit d0c501b
Copy full SHA for d0c501b

File tree

Expand file treeCollapse file tree

11 files changed

+3774
-9
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+3774
-9
lines changed

‎doc/api/api_changes.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes.rst
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ Changes in 1.2.x
6565
:class:`~matplotlib.colorbar.ColorbarBase` allows one to control the size of
6666
the triangular minimum and maximum extensions on colorbars.
6767

68+
* A new keyword *capthick* in :meth:`~matplotlib.pyplot.errorbar` has been
69+
added as an intuitive alias to the *markeredgewidth* and *mew* keyword
70+
arguments, which indirectly controlled the thickness of the caps on
71+
the errorbars. For backwards compatibility, specifying either of the
72+
original keyword arguments will override any value provided by
73+
*capthick*.
74+
6875
Changes in 1.1.x
6976
================
7077

‎examples/pylab_examples/errorbar_demo.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/errorbar_demo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
yerr_lower = y - ylower
4040

4141
ax.errorbar(x, y, yerr=[yerr_lower, 2*yerr], xerr=xerr,
42-
fmt='o', ecolor='g')
42+
fmt='o', ecolor='g', capthick=2)
4343
ax.set_title('Mixed sym., log y')
4444

4545
fig.suptitle('Variable errorbars')

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+25-6Lines 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 length 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

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,8 @@ def csd(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
25332533
@autogen_docstring(Axes.errorbar)
25342534
def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
25352535
capsize=3, barsabove=False, lolims=False, uplims=False,
2536-
xlolims=False, xuplims=False, errorevery=1, hold=None, **kwargs):
2536+
xlolims=False, xuplims=False, errorevery=1, capthick=None,
2537+
hold=None, **kwargs):
25372538
ax = gca()
25382539
# allow callers to override the hold state by passing hold=True|False
25392540
washold = ax.ishold()
@@ -2545,7 +2546,7 @@ def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
25452546
elinewidth=elinewidth, capsize=capsize,
25462547
barsabove=barsabove, lolims=lolims, uplims=uplims,
25472548
xlolims=xlolims, xuplims=xuplims,
2548-
errorevery=errorevery, **kwargs)
2549+
errorevery=errorevery, capthick=capthick, **kwargs)
25492550
draw_if_interactive()
25502551
finally:
25512552
ax.hold(washold)
Binary file not shown.
Loading

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.