I want to create a polar bar plot with error bars in matplotlib. When I use the following code all my error bars have a horizontal alignment, and it looks wrong, unless the bar corresponds to the 90 or 270 degree case.
from numpy import *
from matplotlib import pyplot as py
r=zeros([16])
err=zeros([16])
for i in range(16):
r[i]=random.randint(400,600)
err[i]=random.randint(20,50)
theta=arange(0,2*pi,2*pi/16)
width = pi*2/16
fig = py.figure(figsize=(8,8))
ax = fig.add_axes([0.1, 0.1, 0.75, 0.79], polar=True)
bars = ax.bar(theta+pi/16, r, width=width, bottom=0.0,yerr=err)
ax.set_ylim(0,700)
py.show()

How to I get the error bars to take the theta of the individual bar into account?
So, it appears that the error bars are created with a Line2D object; that is, a dashed line is plotted with data points corresponding to the error bar positions (x[i],y[i]+yerr[i]). The dashes in the line are always the same, because they are just symbols. This obviously does not work for the polar plot. So this error bar setup needs to be deleted and each error bar must be added individually, with a line having the correct orientation.
Here is a routine that does this: