我正在处理生成以下graph的长代码。
问题是误差条由于对数刻度而改变了它们的长度,并且我希望它们看起来彼此相等,即具有固定的长度。有没有办法用Python轻松完成这个?
编辑:以下是代码的一部分,我生成错误栏。
faztec=[11.4,11.4,7.1,7.7,6.8,6.9,6.2,7.5,5.5,4.0,3.5,3.2,2.9,2.9]
flaboca=[9.8,7.3,6.8,8.2,6.8,8.1,6.7,11.0,10.6,4.2,7.0,7.1,5.0,5.3]
err1 = [1.5,1.5,1.7,1.8,1.4,1.5,1.7,3.0,2.7,1.4,1.9,1.9,1.4,1.8]
err2 = [0.7,0.7,0.7,0.8,0.7,0.7,0.7,0.9,0.7,0.7,0.7,0.7,0.7,0.7]
newErr1x = []
newErr1y = []
for i in range(0, len(y)):
x1 = x[i]
y1 = (flaboca[i]-err1[i])/(faztec[i]+err2[i])
x2 = x[i]
y2 = (flaboca[i]+err1[i])/(faztec[i]-err2[i])
pl.plot([x1, x2], [y1, y2])
correction = False
# when end of segment is near 0, we must change it (because of logx)
if x2 < endBarLen:
x2 = 0.03
endBarLen = endBarLen / 10
correction = True
pl.plot([x1+endBarLen, x2-endBarLen], [y1, y1], '-k')
pl.plot([x1+endBarLen, x2-endBarLen], [y2, y2], '-k')
if correction:
correction = False
endBarLen = endBarLen*10
pl.show()
答案 0 :(得分:0)
您可能会将数组作为错误传入,但如果您希望它们的长度相同,则应为每个错误栏传入相同的值。看起来您的y轴不是对数刻度 - 如果您希望将值从对数空间转换为线性空间,则可以使用指数或记录错误数据来相应地调整它。如果给出更具体的信息,我将能够提供更具体的答案