Skip to content

Commit

Permalink
Merge pull request #4449 from HDembinski/capsize-default
Browse files Browse the repository at this point in the history
ENH: errorbor capsize rcparam
  • Loading branch information
tacaswell committed Jun 16, 2015
2 parents ab101e9 + 2146f24 commit 61591cf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
5 changes: 5 additions & 0 deletions doc/users/whats_new/rcparams.rst
@@ -1,3 +1,8 @@
Added ``errorbar.capsize`` key to rcParams
``````````````````````````````````````````
Controls the length of end caps on error bars. If set to zero, errorbars
are turned off by default.

Added ``xtick.minor.visible`` and ``ytick.minor.visible`` key to rcParams
`````````````````````````````````````````````````````````````````````````
Two new keys to control the minor ticks on x/y axis respectively, default set to ``False`` (no minor ticks on the axis).
Expand Down
21 changes: 14 additions & 7 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -1863,9 +1863,10 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
specifies the color of errorbar(s)
default: None
capsize : integer, optional
capsize : scalar, optional
determines the length in points of the error bar caps
default: 3
default: None, which will take the value from the
``errorbar.capsize`` :data:`rcParam<matplotlib.rcParams>`.
error_kw : dict, optional
dictionary of kwargs to be passed to errorbar method. *ecolor* and
Expand Down Expand Up @@ -1931,7 +1932,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
yerr = kwargs.pop('yerr', None)
error_kw = kwargs.pop('error_kw', dict())
ecolor = kwargs.pop('ecolor', None)
capsize = kwargs.pop('capsize', 3)
capsize = kwargs.pop('capsize', rcParams["errorbar.capsize"])
error_kw.setdefault('ecolor', ecolor)
error_kw.setdefault('capsize', capsize)

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

@docstring.dedent_interpd
def errorbar(self, x, y, yerr=None, xerr=None,
fmt='', ecolor=None, elinewidth=None, capsize=3,
fmt='', ecolor=None, elinewidth=None, capsize=None,
barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False, errorevery=1, capthick=None,
**kwargs):
Expand All @@ -2596,7 +2599,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
Call signature::
errorbar(x, y, yerr=None, xerr=None,
fmt='', ecolor=None, elinewidth=None, capsize=3,
fmt='', ecolor=None, elinewidth=None, capsize=None,
barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False, errorevery=1,
capthick=None)
Expand Down Expand Up @@ -2633,7 +2636,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
The linewidth of the errorbar lines. If *None*, use the linewidth.
*capsize*: scalar
The length of the error bar caps in points
The length of the error bar caps in points; if *None*, it will
take the value from ``errorbar.capsize``
:data:`rcParam<matplotlib.rcParams>`.
*capthick*: scalar
An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This
Expand Down Expand Up @@ -2786,6 +2791,8 @@ def xywhere(xs, ys, mask):
return xs, ys

plot_kw = {'label': '_nolegend_'}
if capsize is None:
capsize = rcParams["errorbar.capsize"]
if capsize > 0:
plot_kw['ms'] = 2. * capsize
if capthick is not None:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Expand Up @@ -2786,7 +2786,7 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
# changes will be lost
@_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,
capsize=None, barsabove=False, lolims=False, uplims=False,
xlolims=False, xuplims=False, errorevery=1, capthick=None,
hold=None, **kwargs):
ax = gca()
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/rcsetup.py
Expand Up @@ -623,6 +623,9 @@ def __call__(self, s):
validate_negative_linestyle_legacy],
'contour.corner_mask': [True, validate_corner_mask],

# errorbar props
'errorbar.capsize': [3, validate_float],

# axes props
'axes.axisbelow': [False, validate_bool],
'axes.hold': [True, validate_bool],
Expand Down
3 changes: 3 additions & 0 deletions matplotlibrc.template
Expand Up @@ -363,6 +363,9 @@ backend : %(backend)s
#contour.negative_linestyle : dashed # dashed | solid
#contour.corner_mask : True # True | False | legacy

### ERRORBAR PLOTS
#errorbar.capsize : 3 # length of end cap on error bars in pixels

### Agg rendering
### Warning: experimental, 2008/10/10
#agg.path.chunksize : 0 # 0 to disable; values in the range
Expand Down

0 comments on commit 61591cf

Please sign in to comment.