diff --git a/doc/users/whats_new/rcparams.rst b/doc/users/whats_new/rcparams.rst index 38ffeeeadef6..7adcf42425df 100644 --- a/doc/users/whats_new/rcparams.rst +++ b/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). diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9e11d0d4530f..e2da0611123a 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1860,9 +1860,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`. error_kw : dict, optional dictionary of kwargs to be passed to errorbar method. *ecolor* and @@ -1928,7 +1929,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) @@ -2189,8 +2190,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`. error_kw : dictionary of kwargs to be passed to errorbar method. `ecolor` and @@ -2583,7 +2586,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): @@ -2593,7 +2596,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) @@ -2630,7 +2633,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`. *capthick*: scalar An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This @@ -2783,6 +2788,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: diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index a44d8e15c730..b3902e1b8cd1 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2751,7 +2751,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() diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 0f026f52a85f..023c91e49d85 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -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], diff --git a/matplotlibrc.template b/matplotlibrc.template index f9ee4f8807bb..1f640b91aba9 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -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