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

2009-07-07 Thread Matthias Michler
Hi Ondrej,

I'm not sure where to find a good explanation of that, but let me give you 
some hints. It is intended to use show only once per program. Namely 'show' 
should be the last line in your script. If you want interactive plotting you 
may consider interactive mode (pyplot.ion-ioff) like in the example below. 

Furthermore for dynamic plotting all animation demos might be useful.

Maybe you want to have also a look at 
http://matplotlib.sourceforge.net/users/shell.html .

best regards Matthias


from pylab import *

t = linspace(0.0, pi, 100)
x = cos(t)
y = sin(t)

ion()  # turn on interactive mode
figure(0)
subplot(111, autoscale_on=False, xlim=(-1.2, 1.2), ylim=(-.2, 1.2))

point = plot([x[0]], [y[0]], marker='o', mfc='r', ms=3)

for j in arange(len(t)):
# reset x/y-data of point
setp(point[0], data=(x[j], y[j]))
draw() # redraw current figure

ioff() # turn off interactive mode
show()


On Monday 06 July 2009 08:13:37 Ondrej Certik wrote:
> 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


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplot Numpy possible bug !

2009-07-07 Thread Matthias Michler
Hi Jerome,

although your problem seems to solved, I would like to state a small remark 
about the different number of bins. Some time ago numpy changed the default 
of using left bin edges to using all bin edges. Newer versions of matplotlib 
handle this difference pretty well, but maybe your old version didn't know 
about this quite new numpy feature. I faced this problem some month ago as an 
old script got sticked and raised some weird error. As Sandro suggested the 
best way is to update matplotlib.

best regards Matthias


On Monday 22 June 2009 13:33:46 jmariette wrote:
> Hi everybody,
> I have some probleme with Matplot/numpy !
> I'm using matplot v0.91.2 and I'm trying to get the hist function working
> !!
>
> I'm using the sample code of matplot:
>
> --
> #!/usr/bin/env python
> import numpy as np
> import matplotlib.mlab as mlab
> import matplotlib.pyplot as plt
>
> mu, sigma = 100, 15
> x = mu + sigma*np.random.randn(1)
>
> # the histogram of the data
> n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
>
> print len(n)
> print len(bins)
>
> print n
> print bins
>
> # add a 'best fit' line
> y = mlab.normpdf( bins, mu, sigma)
> l = plt.plot(bins, y, 'r--', linewidth=1)
>
> plt.xlabel('Smarts')
> plt.ylabel('Probability')
> plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
> plt.axis([40, 160, 0, 0.03])
> plt.grid(True)
>
> plt.show()
> 
>
> With the same matplot lib but a different version of numpy I get 2
> different number of bins !!! How is that possible ???
> using the 1.0.4 version of numpy, I get len(n) = 50 and len(bins) = 50 ...
> what sounds pretty right to me !! but using the version 1.2.1 (the last one
> I guess) I got len(n) = 50 and len(bins) = 51 What looks weird, doesn't it
> ???
>
> do you guys have an explanation ??
> Anybody faced the same problem ?
>
> thx, Jerome



--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] 3D Bar (histogram) question

2009-07-07 Thread Nicolas Bigaouette
Hi,

I compiled matplotlib svn revision 7246 yesterday to try the 3D stuff.

>From mpl's website, an example for 3D bar plotting is shown[1]. I just don't
understand the axes. From the code, shouldn't X values go from 0 to 20,
instead of 0 to 400 000 like shown on the graph? Where does these values for
the X and Z axes comes from (in the graph)?

I'm trying my own 3D bar plot, with similar "weird" results.

Could it be a bug?

Thanx a lot.

[1] http://matplotlib.sourceforge.net/examples/mplot3d/bars3d_demo.html
--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Add units to plots?

2009-07-07 Thread Joseph Smidt
I have several plots where the scientific notation exponential
overflows to the top of the plot like this:
http://matplotlib.sourceforge.net/examples/pylab_examples/plotfile_demo.html.

Is there any way to add units to this?  So that, if I wanted, the
units would show up in the overflow as: 1e8 m^3 , for meters cubed?

Also, is there an easy way to add units to the numbers on the x or y
axis in general?  Thanks.

 Joseph Smidt

-- 

Joseph Smidt 

Physics and Astronomy
4129 Frederick Reines Hall
Irvine, CA 92697-4575
Office: 949-824-3269

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Mauro Cavalcanti
Dear Jeff & ALL,

In trying to freeze my app using bb-freeze
(http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
the app is correctly freezed, but it then looks for the Basemap
datafiles and since cannot find them, fails to start (with a message
complaining that the above mentioned files are missing). So, my
question is: can Basemap data files be installed in a directory other
than the default one? And if so, how to instruct a program to look for
them in another location?

Thanks in advance for any assistance you can provide.

Best regards,

-- 
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: mauro...@gmail.com
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] histograms : xmax

2009-07-07 Thread Pau
Hello,

two days ago Sebastian helped me to finish in a hurry a histogram with bar()

I would like now to understand how to make the plot with hist()

First of all, my data (after a massage) looks like :

-
0.00e+00   1.00e-04 81039
1.00e-04   2.00e-04 4472
2.00e-04   3.00e-04 2033
3.00e-04   4.00e-04 1155
4.00e-04   5.00e-04  823
5.00e-04   6.00e-04  643
6.00e-04   7.00e-04  534
7.00e-04   8.00e-04  361
8.00e-04   9.00e-04  313
9.00e-04   1.00e-03  269
1.00e-03   1.10e-03  230
1.10e-03   1.20e-03  195
1.20e-03   1.30e-03  178
1.30e-03   1.40e-03  165
1.40e-03   1.50e-03  175
1.50e-03   1.60e-03  125
1.60e-03   1.70e-03  109
1.70e-03   1.80e-03  112
1.80e-03   1.90e-03   90
.
.
.
.
9.86e-02   9.87e-020
9.87e-02   9.88e-020
9.88e-02   9.89e-020
9.89e-02   9.90e-020
9.90e-02   9.91e-020
9.91e-02   9.92e-020
9.92e-02   9.93e-020
9.93e-02   9.94e-020
9.94e-02   9.95e-020
9.95e-02   9.96e-021
-

The bins are given by the two first number columns.

For instance, the first bin is from 0.00e+00 to 1.00e-04 and has the
number of data 81039

Then I run the following script on them:

--
#!/usr/bin/env python

from pylab import *

H = load ( './histo3.dat')

h =  H[:, 2]  # the third column

n, bins, patches = hist(h, 997, normed=0, log=0,
facecolor='lightblue', alpha=0.75)

show()
--

The number 997 is because this is the number of lines I have in my
file (and, thus, the number of bins)

But the plot is ranging between

0 - 9 --> on x axis
0 - 1000   --> on y axis

Notice in the data file that x does not get further than 9.96e-02

So the maximum should be 0.0996 and I am getting 9

Why is that?

What am I doing wrong?

I have tried to substitute lower-case e with E in the data file but
this did not help

Any help would be appreciated.

thanks,

Pau

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


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

2009-07-07 Thread Ondrej Certik
Hi Matthias!

many thanks for the help, that was it. I will now remember to use
show() only once and use other techniques to create something like
show(), but that can be called multiple times.

Thanks,
Ondrej

On Tue, Jul 7, 2009 at 5:35 AM, Matthias Michler wrote:
> Hi Ondrej,
>
> I'm not sure where to find a good explanation of that, but let me give you
> some hints. It is intended to use show only once per program. Namely 'show'
> should be the last line in your script. If you want interactive plotting you
> may consider interactive mode (pyplot.ion-ioff) like in the example below.
>
> Furthermore for dynamic plotting all animation demos might be useful.
>
> Maybe you want to have also a look at
> http://matplotlib.sourceforge.net/users/shell.html .
>
> best regards Matthias
>
> 
> from pylab import *
>
> t = linspace(0.0, pi, 100)
> x = cos(t)
> y = sin(t)
>
> ion()  # turn on interactive mode
> figure(0)
> subplot(111, autoscale_on=False, xlim=(-1.2, 1.2), ylim=(-.2, 1.2))
>
> point = plot([x[0]], [y[0]], marker='o', mfc='r', ms=3)
>
> for j in arange(len(t)):
>    # reset x/y-data of point
>    setp(point[0], data=(x[j], y[j]))
>    draw() # redraw current figure
>
> ioff() # turn off interactive mode
> show()
> 
>
> On Monday 06 July 2009 08:13:37 Ondrej Certik wrote:
>> 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
>
>
> --
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/blackberry
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Jeff Whitaker
Mauro Cavalcanti wrote:
> Dear Jeff & ALL,
>
> In trying to freeze my app using bb-freeze
> (http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
> the app is correctly freezed, but it then looks for the Basemap
> datafiles and since cannot find them, fails to start (with a message
> complaining that the above mentioned files are missing). So, my
> question is: can Basemap data files be installed in a directory other
> than the default one? And if so, how to instruct a program to look for
> them in another location?
>
> Thanks in advance for any assistance you can provide.
>
> Best regards,
>
>   
Mauro:  If you set the env var BASEMAPDATA, it will look for the basemap 
data files there.  There is no way supported way to install the files in 
a different directory using setup.py, so if you want them somewhere 
other than the default location you'll have to install them there manually.

-Jeff

-- 
Jeffrey S. Whitaker Phone  : (303)497-6313
Meteorologist   FAX: (303)497-6449
NOAA/OAR/PSD  R/PSD1Email  : jeffrey.s.whita...@noaa.gov
325 BroadwayOffice : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Mauro Cavalcanti
Dear Jeff,

Thanks for your fast reply. No problem with manually installing the
Basemap data files -- indeed, this is just what I do intend in order
to create a frozen application. But other than setting up the
BASEMAPDATA environment variable, is there any way to tell an
application to look for the data in a specific directory?

Best regards,

2009/7/7 Jeff Whitaker :
> Mauro Cavalcanti wrote:
>>
>> Dear Jeff & ALL,
>>
>> In trying to freeze my app using bb-freeze
>> (http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
>> the app is correctly freezed, but it then looks for the Basemap
>> datafiles and since cannot find them, fails to start (with a message
>> complaining that the above mentioned files are missing). So, my
>> question is: can Basemap data files be installed in a directory other
>> than the default one? And if so, how to instruct a program to look for
>> them in another location?
>>
>> Thanks in advance for any assistance you can provide.
>>
>> Best regards,
>>
>>
>
> Mauro:  If you set the env var BASEMAPDATA, it will look for the basemap
> data files there.  There is no way supported way to install the files in a
> different directory using setup.py, so if you want them somewhere other than
> the default location you'll have to install them there manually.
>
> -Jeff
>
> --
> Jeffrey S. Whitaker         Phone  : (303)497-6313
> Meteorologist               FAX    : (303)497-6449
> NOAA/OAR/PSD  R/PSD1        Email  : jeffrey.s.whita...@noaa.gov
> 325 Broadway                Office : Skaggs Research Cntr 1D-113
> Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg
>
>



-- 
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: mauro...@gmail.com
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Where to put MPL/Basemap data files?

2009-07-07 Thread Jeff Whitaker
Mauro Cavalcanti wrote:
> Dear Jeff,
>
> Thanks for your fast reply. No problem with manually installing the
> Basemap data files -- indeed, this is just what I do intend in order
> to create a frozen application. But other than setting up the
> BASEMAPDATA environment variable, is there any way to tell an
> application to look for the data in a specific directory?
>
>   

No.

-Jeff
> Best regards,
>
> 2009/7/7 Jeff Whitaker :
>   
>> Mauro Cavalcanti wrote:
>> 
>>> Dear Jeff & ALL,
>>>
>>> In trying to freeze my app using bb-freeze
>>> (http://pypi.python.org/pypi/bbfreeze/), I stumbled upon a problem:
>>> the app is correctly freezed, but it then looks for the Basemap
>>> datafiles and since cannot find them, fails to start (with a message
>>> complaining that the above mentioned files are missing). So, my
>>> question is: can Basemap data files be installed in a directory other
>>> than the default one? And if so, how to instruct a program to look for
>>> them in another location?
>>>
>>> Thanks in advance for any assistance you can provide.
>>>
>>> Best regards,
>>>
>>>
>>>   
>> Mauro:  If you set the env var BASEMAPDATA, it will look for the basemap
>> data files there.  There is no way supported way to install the files in a
>> different directory using setup.py, so if you want them somewhere other than
>> the default location you'll have to install them there manually.
>>
>> -Jeff
>>
>> --
>> Jeffrey S. Whitaker Phone  : (303)497-6313
>> Meteorologist   FAX: (303)497-6449
>> NOAA/OAR/PSD  R/PSD1Email  : jeffrey.s.whita...@noaa.gov
>> 325 BroadwayOffice : Skaggs Research Cntr 1D-113
>> Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg
>>
>>
>> 
>
>
>
>   


--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] _tkinter problem

2009-07-07 Thread Paul Simon
I have the "tkinter" problem and need some assistance to straighten it out. 
>From the web page "http://wiki.python.org/moin/TkInter"; I tested as in "step 
1" and cannot import "_tkinter." I do not have that file on my computer, but 
do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the 
directories /usr/lib/tk8.5 and /usr/lib/tcl8.5.
This matplotlib and python stuff is great, but the documentation frequently 
feels like it is just a bit out of my grasp. I realize that all of this is 
free but I understand the instructions on the web page to repair only to the 
point of confusion. I'm not an expert. How do I modify my python 
configuration? Is there a file that needs to be edited? Which setup.py file 
do I use? Make? or python setup.py build and python setup.py install?
Thanks. I appreciate your help.
Paul Simon 



--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users