Pau wrote: > ... > 2009/7/5 Gökhan SEVER <[email protected]>: >> On Sun, Jul 5, 2009 at 3:41 PM, Pau <[email protected]> wrote: >>> ... >>> Traceback (most recent call last): >>> File "./prova.py", line 14, in <module> >>> y.append(int(line.split('(')[1].split(')')[0])) >>> IndexError: list index out of range >>>> 2009/7/5 Sebastian Busch <[email protected]>: >>>>> Pau wrote: >>>>>> (2226):********************************************************************************************** >>>>>> 1: 1.00e-04 - 2.00e-04 ( 482):*********************
hey there,
what the line should do is to get the number out of the lengthy text. it
should take what is behind a "(" and before a ")". my guess is that in
some line of your textfile, there is no bracket. give this a try:
from scipy import *
from matplotlib.pyplot import *
from string import split
f = open("histo.dat")
data = f.readlines()
f.close()
x, y, dy = [], [], []
for i, line in enumerate(data):
try:
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
except:
pass
bar(x, y, yerr=dy, align='center')
show()
which will skip any error. but check if your data made it into "y" or
were skipped as well! ;)
best,
sebastian.
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------
_______________________________________________ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
