Home > Enterprise >  Polarplot errorbar maplotlib
Polarplot errorbar maplotlib

Time:10-13

I am stuck with a trivial problem on how to make in a polar plot the error bars radial. Here is my code:

#definition of the inerpolated red curve
tck = interpolate.splrep(phi_mol1D, MFPAD,s=0)
xnew = np.arange(-180, 180, 0.5)
ynew = interpolate.splev(xnew, tck)

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
#plotting the red curve
plt.plot(xnew/180.*np.pi, ynew, c="r", alpha=0.5)
#error bars at each point
plt.errorbar(phi_mol1D/180.*np.pi, MFPAD, yerr=MFPADerr, mec='green', fmt="o", color="b", lw= 20, ms=5) 
#adjustments
ax.set_rticks([2000,4000,6000, 8000])
ax.set_yticklabels([])
ax.grid(True)

The result is the following, where the error bars aretangential i.e. rotated 90° compared to what I would expect. I have just noticed that the thickness of the errorbars is proportional to their distance from the centre, which shouldn't be.

polar plot with errorbars

I have seen corrected version with the right errobars

if anyone knows how to move the degree labels radially, that would be awesome. I apologize for the unuseful post.

  • Related