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

Skip to content

Commit 61591cf

Browse files
committed
Merge pull request #4449 from HDembinski/capsize-default
ENH: errorbor capsize rcparam
2 parents ab101e9 + 2146f24 commit 61591cf

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

doc/users/whats_new/rcparams.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Added ``errorbar.capsize`` key to rcParams
2+
``````````````````````````````````````````
3+
Controls the length of end caps on error bars. If set to zero, errorbars
4+
are turned off by default.
5+
16
Added ``xtick.minor.visible`` and ``ytick.minor.visible`` key to rcParams
27
`````````````````````````````````````````````````````````````````````````
38
Two new keys to control the minor ticks on x/y axis respectively, default set to ``False`` (no minor ticks on the axis).

lib/matplotlib/axes/_axes.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,9 +1863,10 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
18631863
specifies the color of errorbar(s)
18641864
default: None
18651865
1866-
capsize : integer, optional
1866+
capsize : scalar, optional
18671867
determines the length in points of the error bar caps
1868-
default: 3
1868+
default: None, which will take the value from the
1869+
``errorbar.capsize`` :data:`rcParam<matplotlib.rcParams>`.
18691870
18701871
error_kw : dict, optional
18711872
dictionary of kwargs to be passed to errorbar method. *ecolor* and
@@ -1931,7 +1932,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
19311932
yerr = kwargs.pop('yerr', None)
19321933
error_kw = kwargs.pop('error_kw', dict())
19331934
ecolor = kwargs.pop('ecolor', None)
1934-
capsize = kwargs.pop('capsize', 3)
1935+
capsize = kwargs.pop('capsize', rcParams["errorbar.capsize"])
19351936
error_kw.setdefault('ecolor', ecolor)
19361937
error_kw.setdefault('capsize', capsize)
19371938

@@ -2192,8 +2193,10 @@ def barh(self, bottom, width, height=0.8, left=None, **kwargs):
21922193
ecolor : scalar or array-like, optional, default: None
21932194
specifies the color of errorbar(s)
21942195
2195-
capsize : integer, optional, default: 3
2196+
capsize : scalar, optional
21962197
determines the length in points of the error bar caps
2198+
default: None, which will take the value from the
2199+
``errorbar.capsize`` :data:`rcParam<matplotlib.rcParams>`.
21972200
21982201
error_kw :
21992202
dictionary of kwargs to be passed to errorbar method. `ecolor` and
@@ -2586,7 +2589,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
25862589

25872590
@docstring.dedent_interpd
25882591
def errorbar(self, x, y, yerr=None, xerr=None,
2589-
fmt='', ecolor=None, elinewidth=None, capsize=3,
2592+
fmt='', ecolor=None, elinewidth=None, capsize=None,
25902593
barsabove=False, lolims=False, uplims=False,
25912594
xlolims=False, xuplims=False, errorevery=1, capthick=None,
25922595
**kwargs):
@@ -2596,7 +2599,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
25962599
Call signature::
25972600
25982601
errorbar(x, y, yerr=None, xerr=None,
2599-
fmt='', ecolor=None, elinewidth=None, capsize=3,
2602+
fmt='', ecolor=None, elinewidth=None, capsize=None,
26002603
barsabove=False, lolims=False, uplims=False,
26012604
xlolims=False, xuplims=False, errorevery=1,
26022605
capthick=None)
@@ -2633,7 +2636,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
26332636
The linewidth of the errorbar lines. If *None*, use the linewidth.
26342637
26352638
*capsize*: scalar
2636-
The length of the error bar caps in points
2639+
The length of the error bar caps in points; if *None*, it will
2640+
take the value from ``errorbar.capsize``
2641+
:data:`rcParam<matplotlib.rcParams>`.
26372642
26382643
*capthick*: scalar
26392644
An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This
@@ -2786,6 +2791,8 @@ def xywhere(xs, ys, mask):
27862791
return xs, ys
27872792

27882793
plot_kw = {'label': '_nolegend_'}
2794+
if capsize is None:
2795+
capsize = rcParams["errorbar.capsize"]
27892796
if capsize > 0:
27902797
plot_kw['ms'] = 2. * capsize
27912798
if capthick is not None:

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2786,7 +2786,7 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
27862786
# changes will be lost
27872787
@_autogen_docstring(Axes.errorbar)
27882788
def errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None,
2789-
capsize=3, barsabove=False, lolims=False, uplims=False,
2789+
capsize=None, barsabove=False, lolims=False, uplims=False,
27902790
xlolims=False, xuplims=False, errorevery=1, capthick=None,
27912791
hold=None, **kwargs):
27922792
ax = gca()

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@ def __call__(self, s):
623623
validate_negative_linestyle_legacy],
624624
'contour.corner_mask': [True, validate_corner_mask],
625625

626+
# errorbar props
627+
'errorbar.capsize': [3, validate_float],
628+
626629
# axes props
627630
'axes.axisbelow': [False, validate_bool],
628631
'axes.hold': [True, validate_bool],

matplotlibrc.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ backend : %(backend)s
363363
#contour.negative_linestyle : dashed # dashed | solid
364364
#contour.corner_mask : True # True | False | legacy
365365

366+
### ERRORBAR PLOTS
367+
#errorbar.capsize : 3 # length of end cap on error bars in pixels
368+
366369
### Agg rendering
367370
### Warning: experimental, 2008/10/10
368371
#agg.path.chunksize : 0 # 0 to disable; values in the range

0 commit comments

Comments
 (0)