From 2eefb4da51fc6d362124583b43fb1b38495a0476 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Wed, 20 May 2015 20:49:01 -0400 Subject: [PATCH 1/4] take capsize from rcParams, key: errorbar.capsize --- lib/matplotlib/axes/_axes.py | 16 +++++++++++----- lib/matplotlib/rcsetup.py | 3 +++ matplotlibrc.template | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9e11d0d4530f..b9c472c74fbf 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1862,7 +1862,8 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs): capsize : integer, 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 : integer, 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): @@ -2630,7 +2633,8 @@ 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 +2787,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/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 From c4da24747c295bb47b0ba82950e466e7b6644a3e Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Wed, 20 May 2015 20:58:42 -0400 Subject: [PATCH 2/4] fix default in other calls --- lib/matplotlib/axes/_axes.py | 2 +- lib/matplotlib/pyplot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index b9c472c74fbf..2b35be1e637b 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -2596,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) 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() From b89baf3f9842a62e499b6351fcc9724a5ead2e27 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Thu, 21 May 2015 09:20:01 -0400 Subject: [PATCH 3/4] fixes after tacaswell's review --- lib/matplotlib/axes/_axes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 2b35be1e637b..e2da0611123a 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1860,7 +1860,7 @@ 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: None, which will take the value from the ``errorbar.capsize`` :data:`rcParam`. @@ -2190,7 +2190,7 @@ 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 + 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`. @@ -2634,7 +2634,8 @@ def errorbar(self, x, y, yerr=None, xerr=None, *capsize*: scalar The length of the error bar caps in points; if *None*, it will - take the value from ``errorbar.capsize`` :data:`rcParam`. + take the value from ``errorbar.capsize`` + :data:`rcParam`. *capthick*: scalar An alias kwarg to *markeredgewidth* (a.k.a. - *mew*). This From 2146f24602e7b5a0a1f14ccf87210dfcb3f687b7 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Thu, 21 May 2015 09:23:30 -0400 Subject: [PATCH 4/4] added comment as requested by tacaswell --- doc/users/whats_new/rcparams.rst | 5 +++++ 1 file changed, 5 insertions(+) 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).