这是我的问题:
我有一些物理数据表示-90至90度之间的角度。存在与此数据相关的已知错误。我正在使用numpy和matplotlib在python3中工作。_我想为每个测量绘制带有误差线的数据。角度范围从-90到90,并且误差不应超出这些范围。例如,对于85 +/- 10度的角度,我希望上方的误差线循环回到-85,而不是回到95。
_有可能吗?怎么样?我正在尝试使用$ plt.fill_between()$或$ plt.errorbar()$,但是它不起作用。在上面的示例中,即使我尝试将错误栏强制设为-85,该错误也不会循环显示90 ...
以下是一些示例:
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(10) #time
a = np.linspace(50,89,10) #fake angle value
e = np.array([10]*10) #error value
a_up = a + e #Upper error bars
a_low = a - e #Lower error bars
f,ax = plt.subplots(nrows=2,ncols=2)
###Simple error graph,I don't want it because error bars outside of [-90,90]
ax[0,0].errorbar(t,a,yerr = e) #Plot the errors as error bars
### Same but with shaded area
ax[0,1].fill_between(t,a_low,a_up) #Plot the errors as filled region
ax[0,1].plot(t,"*r")
###My best option right now,put an upper limit everywhere
for i,u in enumerate(a_up):
if u > 90:
a_up[i] = 90
ax[1,0].fill_between(t,a_up) #Plot the errors
ax[1,0].plot(t,"*r")
###Finally,force all errorbars in [-90,90] (Just for this exemple,it's generalized in my code)
for i,u in enumerate(a_up):
if u >= 90:
a_up[i] -= 90
ax[1,"*r")
plt.show()
我希望我已经足够清楚,我无法在网络上找到解决方案...也许我不知道该如何制定。
预先感谢您的帮助,在使用您的答案10年之后,我终于有机会提出一个问题! :)
莱奥