Hi fellow developers,I am using matplotlib in particle physics where we generally do not plot the little end caps of error bars. They add no information, but they make the plot harder to read, especially if it is a busy plot.
In physics, we follow the general aesthetic rule to maximise the "data to ink ratio", which means that the information should be presented with a minimum of optical gimmicks.
So, I end up calling errorbar everytime with capsize=0. I argue that having end caps or not is a global style option, and therefore it makes sense to put this into matplotlibrc.
I prepared a patch in order to do that and would like you to include it into the distribution.
Please tell me what you think of it.
>From cbb2df219068a51ee1556a9318b39d19224bc10e Mon Sep 17 00:00:00 2001 From: Hans Dembinski <hans.dembin...@kit.edu> Date: Thu, 9 Aug 2012 14:02:17 +0200 Subject: [PATCH] get capsize via configuration entry lines.capsize --- lib/matplotlib/axes.py | 12 +++++++----- lib/matplotlib/rcsetup.py | 1 + matplotlibrc.template | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index d2dec62..f29decb 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -4604,7 +4604,7 @@ class Axes(martist.Artist): *yerr* if not None, will be used to generate errorbars on the bar chart *ecolor* specifies the color of any errorbar - *capsize* (default 3) determines the length in + *capsize* determines the length in points of the error bar caps *error_kw* dictionary of kwargs to be passed to errorbar method. *ecolor* and *capsize* @@ -4652,7 +4652,7 @@ class Axes(martist.Artist): 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', None) error_kw.setdefault('ecolor', ecolor) error_kw.setdefault('capsize', capsize) @@ -4882,7 +4882,7 @@ class Axes(martist.Artist): *yerr* if not None, will be used to generate errorbars on the bar chart *ecolor* specifies the color of any errorbar - *capsize* (default 3) determines the length in + *capsize* determines the length in points of the error bar caps *align* 'edge' (default) | 'center' *log* [False|True] False (default) leaves the @@ -5175,14 +5175,14 @@ class Axes(martist.Artist): @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, **kwargs): """ 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) @@ -5337,6 +5337,8 @@ class Axes(martist.Artist): ys = [thisy for thisy, b in zip(ys, mask) if b] return xs, ys + if capsize is None: + capsize = rcParams['lines.capsize'] if capsize > 0: plot_kw = { diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 6df1d4b..e3d3b85 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -379,6 +379,7 @@ defaultParams = { 'lines.solid_joinstyle' : ['round', validate_joinstyle], 'lines.dash_capstyle' : ['butt', validate_capstyle], 'lines.solid_capstyle' : ['projecting', validate_capstyle], + 'lines.capsize' : [3, validate_int], # patch props 'patch.linewidth' : [1.0, validate_float], # line width in points diff --git a/matplotlibrc.template b/matplotlibrc.template index 6ebaac2..2edde14 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -69,6 +69,7 @@ backend : %(backend)s #lines.solid_joinstyle : miter # miter|round|bevel #lines.solid_capstyle : projecting # butt|round|projecting #lines.antialiased : True # render lines in antialised (no jaggies) +#lines.capsize : 3 # size of perpendicular lines at end of error bars ### PATCHES # Patches are graphical objects that fill 2D space, like polygons or -- 1.7.9.5
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel