when using errorbar() it is possible to change the attributes (linethickness
etc.) with setp(). This works really well.
But on the otherhand when you try to set the attributes within the
errorbar()-command it will not work - see the exapmle below.
Finding this a bit disturbing I took a look at "axes.py" where errorbar() is
placed. I found out that the drawing of those bars and caps (also
just beeing lines) are added to the plot without the "**kwargs".
Credulously and optimistic I just added it there and - of course - got an
errormessage. So I made a copy of kwargs in the method errorbar() and poped
out all the keywords which could be problematic (I only found out 'marker',
'ls' and 'linestyle') by
kwargs_bars = kwargs.copy() # make copy of kwargs (not only a
if kwargs.has_key('marker'): # Is the 'marker' keyword given in
marker=kwargs_bars.pop('marker')# filter this entry out (would raise
# error "duplicate keyword argument")
if kwargs.has_key('ls'): # Is the 'ls' keyword given in kwargs?
marker=kwargs_bars.pop('ls') # filter this entry out (vlines, hlines
# would not be drawn)
if kwargs.has_key('linestyle'): # Is the 'linestyle' keyword given
marker=kwargs_bars.pop('linestyle') # in kwargs?
and then added **kwargs_bars to the following vlines, hlines and plots:
barlines.extend( self.hlines(y, x, left,**kwargs_bars) )
barlines.extend( self.hlines(y, x, right,**kwargs_bars) )
caplines.extend( self.plot(left, y, '|', ms=2*capsize,**kwargs_bars) )
caplines.extend( self.plot(right, y, '|', ms=2*capsize,**kwargs_bars) )
and also for yerr.
Now the example below worked fine.
I'm now thinking of two things - the second one of them beeing a
i) I'm not sure if other keywords should also be poped out. I can't imagine
any further problems - but we all know that this means completely
nothing in the wide field of possible errormessages ;-)
ii) Like before you have the ability to set the color of the cap- and
barlines seperatly from the color of the line connecting the points.
The problem mentioned above (you can't change the thickness of the caps and
bars from the errorbar()-command) still persists for 'linestyle'. Therefor
I'm not sure if the confusion existing before is cleared away. Propably not.
Just imagine a user: "I would like to change the style of the bars and caps
to '-.'. Why do I have to use setp() instead of giving it to errorbar()?"
But I hope that the changes in axes.py are helpful.
PS: Would it be more agreeable if I try to create a patch ruther
then sending the codesnippets? If yes: could anyone give me a hint on how
to find information about patches (how t omake them, how to apply
"""This little program shows that it makes an enormous difference
where the properties of the errorbar()-command are set.
a) within the command errorbar(...)
b) seperately with an setp() command
from pylab import *
x = 1.0*arange(N)/(N-1)
yerrors = .02*rand(N) # errors in y
xerrors = .02*rand(N) # errors in x
y = exp(-x) # plain curve
print ("Left : If the features are set with setp() everything works out
error_plot_1 = errorbar(x,y, yerr=yerrors,xerr=xerrors,
print ("Right : But if one uses the command errorbars() itself not.")
error_plot = errorbar(x,y, yerr=yerrors,xerr=xerrors,