error bar line width in bar function, cap width in errorbar function

Hi all,

Changing the linewidth parameter in the bar chart function doesn't
seem to change the error bar width. E.g.

V = (.5,1.)
e = (.2,.3)
bar((0,1), V, yerr=e, linewidth=3,ecolor='k',edgecolor='k')

Produces thick lines around the bars, but thin error bars.

It's possible to get around this by defining error bars in a separate
call to errorbar with the elinewidth parameter (the error bar will
also take the linewidth parameter if undefined - this doesn't happen
with bar()). So you can add error bars to the bar chart with e.g.

w = 1.
bar((0,1), V, width=w, linewidth=3,edgecolor='k')
hold(True)
errorbar((0+w/2,1+w/2),V,e,elinewidth=3,ecolor='k',fmt=None,capsize=10)

However, this doesn't solve the problem completely, because the
resulting chart still has thin cap lines! The best workaround I've
found so far is to simply set capsize=0.

So I have two questions:

1. Is there a way to change error bar line width directly with the bar function?
2. If it is necessary to do this with errorbar(), how can I change the
cap width or thickness?

For my simple plots, life would be easier if bar() would default to
letting linewidth define thickness also for error bars and caps.

Any help would be greatly appreciated.

Best,

Johan

1. Is there a way to change error bar line width directly with the bar function?

Maybe not. It seems that the "bar" function currently does not return
errorbar-related artists. You can find them by looking through
axes.lines and axes.collections, but I don't recommend it.

2. If it is necessary to do this with errorbar(), how can I change the
cap width or thickness?

I think it is best to use a separate errorbar function.
The error bar caps are drawn as markers. So, you need to change
marker-related attributes.

errorbar((0+w/2,1+w/2),V,e,elinewidth=3,ecolor='k',fmt=None,capsize=10, mew=5)

"mew" => "makeredgewidth"

errorbar function returns artists it creates. So, you may change
attributes of these individual artists, say, if you want different
widths for upper caps and lower caps.
See the documentation for more details.

Regards,

-JJ

ยทยทยท

On Thu, Oct 22, 2009 at 8:59 AM, Johan Carlin <johan.carlin@...982...> wrote: