【发布时间】: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。是否可以径向移动角度的标签,使它们不与图形重叠?
感谢您的帮助!
【问题讨论】:
-
这里报告了极坐标图中错误栏的问题github.com/matplotlib/matplotlib/pull/21006,但是 1) 显示的图没有源代码 2) 它似乎涉及 plt.errorbars 但 plt.bar跨度>
标签: matplotlib errorbar