In [1]: vh = (1.5 <= V) & ( V<= 3.5) # select voltages between 1.5 and 3.5 In [2]: l2 = B.linefit(V[vh], I[vh], sig_I[vh]) # fit the line