Re: [Matplotlib-users] Empty squares at end of data after interpolation with griddata?

2009-07-05 Thread Sandro Tosi
Hello Rick,

On Sun, Jul 5, 2009 at 03:52, Rick Muller wrote:
> Having one last problem with matplotlib. I have some data that I'm
> interpolating with griddata, and then plotting with contourf. For reasons
> that escape me, the upper right and the lower left squares are not being
> plotted. I'm printing out a 10x10 version of this to exaggerate the effect:
>
> http://files.getdropbox.com/u/533499/griddata-example-text.png

this link returns a 404. Please attach the image to this email, along
with a minimal program to replicate the problem (if possible).

Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Empty squares at end of data after interpolation with griddata?

2009-07-05 Thread Jeff Whitaker
Rick Muller wrote:
> Having one last problem with matplotlib. I have some data that I'm 
> interpolating with griddata, and then plotting with contourf. For 
> reasons that escape me, the upper right and the lower left squares are 
> not being plotted. I'm printing out a 10x10 version of this to 
> exaggerate the effect:
>
> http://files.getdropbox.com/u/533499/griddata-example-text.png

Rick:  That URL doesn't work.

griddata won't do extrapolation, that is it won't interpolate outside 
the convex hull of the data.  That's probably why you see those empty 
squares at the edges.

-Jeff
>
> In reality, I interpolate/plot this 200x200 squares, and none of it is 
> all that noticeable. However, I'm worried that I'm doing something 
> wrong here, and that the mistake is going to come back and bite me 
> later on. Has anyone seen anything like this?
>
> Thanks for any help you can offer with this, and thank for all of the 
> help the list members have already given me.
>
> Rick
> -- 
> Rick Muller
> [email protected] 
> 
>
> --
>   
> 
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   


--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] histograms ...

2009-07-05 Thread Pau
Hello,

I am trying to make a histogram with matplotlib and I do not
understand the example I found

http://n2.nabble.com/Python-MatPlotLib-histogram-example-td1922503.html

I have a data file called "histo.dat" which looks like

-
#
# Eccentricity on entrance to detector band (finer grain)
#
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):***
.
.
.
 932: 9.32e-02 -  9.33e-02 (   0):
 933: 9.33e-02 -  9.34e-02 (   1):*
-

The * were meant to give an ascii impression of the histogram.

As you can see, I have 933 bins

First bin (MODE, since it's the most frequent one) ranges between
0.00e+00 -  1.00e-04 and has 2226 occurrences

Second bin ranges between 1.00e-04 -  2.00e-04 and has 482 occurrences

Third bin between 3.00e-04 -  4.00e-04 with 273 cases

etc etc

I am supposed to show this plot tomorrow and I cannot figure out how
to plot this with matplotlib

Any help in this desperate last minute panic would be enormously appreciated!

thanks

Pau

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Sebastian Busch
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.



signature.asc
Description: OpenPGP digital signature
--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Pau
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


Pau


2009/7/5 Sebastian Busch :
> 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

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Pau
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 :
> 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
>
>
> Pau
>
>
> 2009/7/5 Sebastian Busch :
>> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Gökhan SEVER
On Sun, Jul 5, 2009 at 3:41 PM, Pau  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 :
> > 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
> >
> >
> > Pau
> >
> >
> > 2009/7/5 Sebastian Busch :
> >> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

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
--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Pau
Hello,

thanks, yes, I had done this already. It's pointing to the append
place for y, but I am absolutely lost at that line. I don't understand
it.

I guess this has to do with the format of the data (see previous e-mail)

---> 13y.append(int(line.split('(')[1].split(')')[0]))

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 :
> On Sun, Jul 5, 2009 at 3:41 PM, Pau  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 :
>> > 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
>> >
>> >
>> > Pau
>> >
>> >
>> > 2009/7/5 Sebastian Busch :
>> >> 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
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> 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

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Gökhan SEVER
OK, You are one step closer to point out the error.

Look for an instance of line. What does it output?

Then try fiddling with the split() function and proper indexes.

Haha, are you a Mediterranean person or what?


On Sun, Jul 5, 2009 at 3:54 PM, Pau  wrote:

> Hello,
>
> thanks, yes, I had done this already. It's pointing to the append
> place for y, but I am absolutely lost at that line. I don't understand
> it.
>
> I guess this has to do with the format of the data (see previous e-mail)
>
> ---> 13y.append(int(line.split('(')[1].split(')')[0]))
>
> 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 :
> > On Sun, Jul 5, 2009 at 3:41 PM, Pau  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 :
> >> > 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
> >> >
> >> >
> >> > Pau
> >> >
> >> >
> >> > 2009/7/5 Sebastian Busch :
> >> >> 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
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> > 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
>



-- 
Gökhan
--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Sebastian Busch
Pau wrote:
> ...
> 2009/7/5 Gökhan SEVER :
>> On Sun, Jul 5, 2009 at 3:41 PM, Pau  wrote:
>>> ...
>>> 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
 2009/7/5 Sebastian Busch :
> 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


Re: [Matplotlib-users] contour plot: clabel manual changes figure properties

2009-07-05 Thread Valentin Flunkert
> Is there some way to prevent this or alternatively set the 
> properties after manually setting the labels?

Hi,

I just found out how to restore the old settings:

save = pl.rcParams.copy()
pl.clabel(cs, manual=True)
pl.rcParams.update(save)

Maybe this should be the default behaviour?

Regards,
Valentin

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histograms ...

2009-07-05 Thread Sebastian Busch
> 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 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).


as a side note:
you might want to use

yscale('log')
and / or
xscale('log')

as your data drop pretty fast.



good luck & good night,
sebastian.



signature.asc
Description: OpenPGP digital signature
--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Fwd: Empty squares at end of data after interpolation with griddata?

2009-07-05 Thread Rick Muller
Meant to copy this to the list as well for completeness.

-- Forwarded message --
From: Rick Muller 
Date: Sun, Jul 5, 2009 at 2:03 PM
Subject: Re: [Matplotlib-users] Empty squares at end of data after
interpolation with griddata?
To: Jeff Whitaker 


The link should work now. What you say about extrapolation makes perfect
sense. I wonder why those points aren't being computed. In any case, thanks
for the help!

Rick

On Sun, Jul 5, 2009 at 7:27 AM, Jeff Whitaker  wrote:

>
> http://files.getdropbox.com/u/533499/griddata-example-text.png
>>
>
>
> Rick:  That URL doesn't work.
>
> griddata won't do extrapolation, that is it won't interpolate outside the
> convex hull of the data.  That's probably why you see those empty squares at
> the edges.
>
> --
Rick Muller
[email protected]



-- 
Rick Muller
[email protected]
--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] calling show() twice in a row

2009-07-05 Thread Ondrej Certik
On Tue, Jun 30, 2009 at 12:09 PM, Ondrej Certik wrote:
> Hi,
>
> this must have been answered many times already, but I searched the
> archives, online docs, but couldn't find anything.
>
> If I do:
>
> $ python
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 import pylab
 pylab.plot([1, 3, 3])
> []
 pylab.show()
 pylab.show()

>
> the first pylab.show() shows the plot and stays hanging (this is ok)
> and then if I close it, to get back to the shell, the second call to
> show() does nothing.
>
> One fix is to use:
>
> ipython --pylab
>
> but if I just want to call regular python, or from my own script ---
> how do I plot for the second time?

I still haven't figured out how to fix it, so any feedback would be appreciated.

Thanks,
Ondrej

--
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users