【问题标题】:Polarplot errorbar maplotlib极坐标图误差条 matplotlib
【发布时间】:2021-10-08 14:49:15
【问题描述】:

关于如何在极坐标图中制作径向误差条,我遇到了一个小问题。这是我的代码:

#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)

结果如下,误差线是相切的,即与我的预期相比旋转了 90°。我刚刚注意到误差条的厚度与它们与中心的距离成正比,这不应该。

我见过this attempt 使用transform=Affine2D().rotate_deg(90) 轮换制造商,但它不适用于我的语法。

PS。是否可以径向移动角度的标签,使它们不与图形重叠?

感谢您的帮助!

【问题讨论】:

标签: matplotlib errorbar


【解决方案1】:

答案非常简单:yerr 的绝对值非常小,而参数lw = 20 用于表示条形的宽度。更正后的版本类似于:

plt.errorbar(phi_mol1D/180.*np.pi, MFPAD, yerr=MFPADerr*10, mec='green', fmt="o", color="b", ms=5) 

返回这个:

如果有人知道如何径向移动度数标签,那就太好了。对于没有用的帖子,我深表歉意。

【讨论】:

    猜你喜欢
    • 2017-05-18
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-12
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多