...
MODE: 0.00e+00 - 1.00e-04
(2226):**********************************************************************************************
1: 1.00e-04 - 2.00e-04 ( 482):*********************
2: 2.00e-04 - 3.00e-04 ( 273):************
3: 3.00e-04 - 4.00e-04 ( 173):********
4: 4.00e-04 - 5.00e-04 ( 125):******
5: 5.00e-04 - 6.00e-04 ( 99):*****
6: 6.00e-04 - 7.00e-04 ( 68):***
...
I am supposed to show this plot tomorrow and I cannot figure out how
to plot this with matplotlib
...
hey!
i'm not sure but maybe you are looking for something like this (will
crash on the text lines in the file -- you may want to add a try:...
except: pass around the split thing.
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):
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
I have removed the text lines (do you mean the ones starting with a
hash, #? I removed those)
It complained about
from scipy import * # complained "ImportError: No module named scipy"
So I commented it out and added
from pylab import *
But it's crashing:
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
where
hux(p2)| cat prova.py
#!/usr/bin/env python
from pylab import * #from scipy import * # complained "ImportError: No module named scipy"
from matplotlib.pyplot import *
from string import split
f = open("histo2.dat")
data = f.readlines()
f.close()
x, y, dy = , ,
for i, line in enumerate(data):
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
bar(x, y, yerr=dy, align='center')
show()
It would be great if I got this one done. Thanks for your help
Pau
2009/7/5 Sebastian Busch <webmaster@...2599...>:
···
Pau wrote:
...
MODE: 0.00e+00 - 1.00e-04
(2226):**********************************************************************************************
1: 1.00e-04 - 2.00e-04 ( 482):*********************
2: 2.00e-04 - 3.00e-04 ( 273):************
3: 3.00e-04 - 4.00e-04 ( 173):********
4: 4.00e-04 - 5.00e-04 ( 125):******
5: 5.00e-04 - 6.00e-04 ( 99):*****
6: 6.00e-04 - 7.00e-04 ( 68):***
...
I am supposed to show this plot tomorrow and I cannot figure out how
to plot this with matplotlib
...
hey!
i'm not sure but maybe you are looking for something like this (will
crash on the text lines in the file -- you may want to add a try:...
except: pass around the split thing.
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):
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
bar(x, y, yerr=dy, align='center')
show()
good luck,
sebastian.
--
Let there be peace on earth. And let it begin with misc
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
what is out of range?
sorry for the spamming...
2009/7/5 Pau <vim.unix@...982...>:
···
Hello!
thanks for the quick answer!
I have removed the text lines (do you mean the ones starting with a
hash, #? I removed those)
It complained about
from scipy import * # complained "ImportError: No module named scipy"
So I commented it out and added
from pylab import *
But it's crashing:
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
where
hux(p2)| cat prova.py
#!/usr/bin/env python
from pylab import * #from scipy import * # complained "ImportError: No module named scipy"
from matplotlib.pyplot import *
from string import split
f = open("histo2.dat")
data = f.readlines()
f.close()
x, y, dy = , ,
for i, line in enumerate(data):
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
bar(x, y, yerr=dy, align='center')
show()
It would be great if I got this one done. Thanks for your help
Pau
2009/7/5 Sebastian Busch <webmaster@...2599...>:
Pau wrote:
...
MODE: 0.00e+00 - 1.00e-04
(2226):**********************************************************************************************
1: 1.00e-04 - 2.00e-04 ( 482):*********************
2: 2.00e-04 - 3.00e-04 ( 273):************
3: 3.00e-04 - 4.00e-04 ( 173):********
4: 4.00e-04 - 5.00e-04 ( 125):******
5: 5.00e-04 - 6.00e-04 ( 99):*****
6: 6.00e-04 - 7.00e-04 ( 68):***
...
I am supposed to show this plot tomorrow and I cannot figure out how
to plot this with matplotlib
...
hey!
i'm not sure but maybe you are looking for something like this (will
crash on the text lines in the file -- you may want to add a try:...
except: pass around the split thing.
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):
x.append(i)
y.append(int(line.split('(')[1].split(')')[0]))
dy.append(sqrt(y[-1]))
bar(x, y, yerr=dy, align='center')
show()
good luck,
sebastian.
--
Let there be peace on earth. And let it begin with misc
--
Let there be peace on earth. And let it begin with misc
First install it if you haven’t and and run your script with %run
magic command. There you will be able to easily pinpoint the index out of range
error.
···
On Sun, Jul 5, 2009 at 3:41 PM, Pau <vim.unix@…982…> wrote:
ok, I installed now scipy
Traceback (most recent call last):
File “./prova.py”, line 14, in
y.append(int(line.split('(')[1].split(')')[0]))
IndexError: list index out of range
what is out of range?
sorry for the spamming…
2009/7/5 Pau <vim.unix@…982…>:
Hello!
thanks for the quick answer!
I have removed the text lines (do you mean the ones starting with a
hash, #? I removed those)
It complained about
from scipy import * # complained “ImportError: No module named scipy”
So I commented it out and added
from pylab import *
But it’s crashing:
Traceback (most recent call last):
File “./prova.py”, line 14, in
y.append(int(line.split(‘(’)[1].split(‘)’)[0]))
IndexError: list index out of range
where
hux(p2)| cat prova.py
#!/usr/bin/env python
from pylab import *
#from scipy import * # complained “ImportError: No module named scipy”
from matplotlib.pyplot import *
from string import split
f = open(“histo2.dat”)
data = f.readlines()
f.close()
x, y, dy = , ,
for i, line in enumerate(data):
x.append(i)
y.append(int(line.split(‘(’)[1].split(‘)’)[0]))
dy.append(sqrt(y[-1]))
bar(x, y, yerr=dy, align=‘center’)
show()
It would be great if I got this one done. Thanks for your help
anyway... thanks for all... I guess that the last minute panic is not
exactly the best strategy, as usual
Pau
2009/7/5 Gökhan SEVER <gokhansever@...287...>:
···
On Sun, Jul 5, 2009 at 3:41 PM, Pau <vim.unix@...982...> wrote:
ok, I installed now scipy
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
what is out of range?
sorry for the spamming...
2009/7/5 Pau <vim.unix@...982...>:
> Hello!
>
> thanks for the quick answer!
>
> I have removed the text lines (do you mean the ones starting with a
> hash, #? I removed those)
>
> It complained about
>
> from scipy import * # complained "ImportError: No module named scipy"
>
> So I commented it out and added
>
> from pylab import *
>
> But it's crashing:
>
> 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
>
> where
>
> hux(p2)| cat prova.py
> #!/usr/bin/env python
> from pylab import *
> #from scipy import * # complained "ImportError: No module named scipy"
> from matplotlib.pyplot import *
> from string import split
>
> f = open("histo2.dat")
> data = f.readlines()
> f.close()
>
> x, y, dy = , ,
> for i, line in enumerate(data):
> x.append(i)
> y.append(int(line.split('(')[1].split(')')[0]))
> dy.append(sqrt(y[-1]))
>
> bar(x, y, yerr=dy, align='center')
> show()
>
> It would be great if I got this one done. Thanks for your help
>
>
> Pau
>
>
> 2009/7/5 Sebastian Busch <webmaster@...2599...>:
>> Pau wrote:
>>> ...
>>> MODE: 0.00e+00 - 1.00e-04
>>>
>>> (2226):**********************************************************************************************
>>> 1: 1.00e-04 - 2.00e-04 ( 482):*********************
>>> 2: 2.00e-04 - 3.00e-04 ( 273):************
>>> 3: 3.00e-04 - 4.00e-04 ( 173):********
>>> 4: 4.00e-04 - 5.00e-04 ( 125):******
>>> 5: 5.00e-04 - 6.00e-04 ( 99):*****
>>> 6: 6.00e-04 - 7.00e-04 ( 68):***
>>> ...
>>> I am supposed to show this plot tomorrow and I cannot figure out how
>>> to plot this with matplotlib
>>> ...
>>
>> hey!
>>
>> i'm not sure but maybe you are looking for something like this (will
>> crash on the text lines in the file -- you may want to add a try:...
>> except: pass around the split thing.
>>
>>
>>
>> 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):
>> x.append(i)
>> y.append(int(line.split('(')[1].split(')')[0]))
>> dy.append(sqrt(y[-1]))
>>
>> bar(x, y, yerr=dy, align='center')
>> show()
>>
>>
>> good luck,
>> sebastian.
>>
>>
>
>
>
> --
> Let there be peace on earth. And let it begin with misc
>
--
Let there be peace on earth. And let it begin with misc
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net matplotlib-users List Signup and Options
Pau,
I recommend you to run this script via ipython.
First install it if you haven't and and run your script with %run magic
command. There you will be able to easily pinpoint the index out of range
error.
--
Gökhan
--
Let there be peace on earth. And let it begin with misc
...
2009/7/5 Gökhan SEVER <gokhansever@...287...>:
...
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
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.
···
On Sun, Jul 5, 2009 at 3:41 PM, Pau <vim.unix@...982...> wrote:
i think it was the last (empty) line which was messing up things. the
following works (at least here.....)
from scipy import *
from matplotlib.pyplot import *
from string import split
f = open("histo2.dat")
data = f.readlines()
f.close()
x, y, dy = , ,
for i, line in enumerate(data):
try:
y.append(int(line.split('(')[1].split(')')[0]))
x.append(i)
dy.append(sqrt(y[-1]))
except:
pass
bar(x, y, yerr=dy, align='center')
show()
main difference is swapping of x and y append(......): if something goes
wrong width y, it won't do x and therefore both will have the same
length in the end (i think it was complaining about the two not having
the same length).