Re: [Matplotlib-users] Forcing full value on axis (Dave Simpson)

2007-04-25 Thread David Simpson
I also had some trouble with exponents in an axis, getting
0.0 to 3.0 on the axis, with +1.998e3. I wanted the years
1998 to 2001 instead. I solved this using the following code
(with the solution bits commented out):

#!/usr/bin/env python
from pylab import *
# from matplotlib.ticker import FormatStrFormatter

x = array([ 1998, 1999, 2000, 2001 ])
y = array([   2.3, 4.5, 2.6, 7.2 ])

# ax=subplot(111)
plot(x,y)

## Needed to get 2001, not 1+2e3:
# majorFormatter=FormatStrFormatter('%d')
# ax.xaxis.set_major_formatter(majorFormatter)
# show()


Dave



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Forcing full value on axis

2007-04-25 Thread John T Whelan
On Tue, 24 Apr 2007, Tommy Grav wrote:

> I have a plot where the x axis ticks are given as

> 0.1  0.15  0.20  0.025  0.30  0.35

> with +3.732e2 given in the lower right of the axis.
> How can I force the ticks to have
> 373.3  373.35 

If all else fails, you can set the tick labels by hand.  For example,
I did this when trying to get tick labels of 0.002, 0.0025, 0.003,
etc.:

tickvals = arange(0.002,0.007,0.0005);
ticklabs = map(lambda val:"%.4f"%val, tickvals);
ticklabs[0:9:2] = map(lambda val:"%.3f"%val, tickvals[0:9:2]);
xticks(tickvals,ticklabs);

-- 
==
Office: 0.17 (Golm) Dr. John T. Whelan
Phone: +49 331 567 7117 MPI for Gravitational Physics
FAX:   +49 331 567 7298 (Albert-Einstein Institute)
http://www.aei.mpg.de/~whelan/  D-14424 Potsdam
[EMAIL PROTECTED][EMAIL PROTECTED]
==


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] question about autoscale_view()

2007-04-25 Thread John Hunter
On 4/23/07, Eric Firing <[EMAIL PROTECTED]> wrote:

> The autoscaling mechanism does not keep track of plot elements, so it
> has no way of knowing what to change when you delete a line.  You will
> have to keep track of the x and y extents of each element yourself, and
> manually reset the xlim and ylim when you want to rescale after deleting
> a line.  This can be done with the Axes set_xlim and set_ylim methods.

I recently added a helper function "relim" in svn in the Axes class to
automatically recomupte the data limits.   After removing various
lines, simply do

  ax.relim()
  ax.autoscale_view()

but you will need svn...

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] confusion about what part of numpy pylab imports

2007-04-25 Thread Mark Bakker

Well, if I can cast a vote, it would make a lot of sense if pylab functions
do the same thing as numpy functions. Right now it is exceedingly confusing
when I teach, that zeros() could be integers or floats. An rc parameter
where we would import straight from numpy would be most excellent. Can't
wait!
Thanks for the explanations,
Mark

On 4/24/07, Eric Firing <[EMAIL PROTECTED]> wrote:


Gary Ruben wrote:
> Hi Mark,
> this thread may help:
>
http://thread.gmane.org/gmane.comp.python.numeric.general/13399/focus=13421
>
> Essentially, pylab uses a compatibility layer to ease the task of
> supporting the three array packages - currently this uses the Numeric
> version of the ones and zeros functions giving the behaviour you observe
> - this will be fixed when pylab drops support for the older packages,
> which should be soon.

What we will do is drop the use of numerix internally, but the numerix
module will almost certainly remain, presumably with the Numeric and
numarray support removed; so numerix will still use numpy's own
"oldnumeric" compatibility layer, and I expect pylab will still import
from it--at least, by default.  The intention is to avoid breaking
things unnecessarily.  I can imagine possible variations, such as using
an rc param to tell pylab whether to import from plain numpy or from
oldnumeric, and splitting pylab into core pylab functions (figure, show,
etc.) versus the convenience all-in-one namespace (mostly from numpy);
but we will take one step at a time.

Eric

>
> Gary R.
>
> Mark Bakker wrote:
>> Hello list -
>>
>> I am confused about the part of numpy that pylab imports.
>> Apparently, pylab imports 'zeros', but not the 'zeros' from numpy, as
it
>> returns integers by default, rather than floats.
>> The same holds for 'ones' and 'empty'.
>> Example:
>>  >>> from pylab import *
>>  >>> zeros(3)
>> array([0, 0, 0])
>>  >>> from numpy import *
>>  >>> zeros(3)
>> array([ 0.,  0.,  0.])
>>
>> Can this be fixed? Any explanation how this happens? Pylab just imports
>> part of numpy, doesn't it?
>>
>> Thanks,
>>
>> Mark
>
>
>
-
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] confusion about what part of nu mpy pylab imports

2007-04-25 Thread Alan G Isaac
On Wed, 25 Apr 2007, Mark Bakker apparently wrote: 
> it would make a lot of sense if pylab functions 
> do the same thing as numpy functions. 

Yes.  This should be the default.
Backward compatability can be provided
via numpy's compatability module.

A user's view,
Alan Isaac




-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Andrew Straw
The May/June issue of Computing in Science and Engineering 
http://computer.org/cise: is out and has a Python theme. Many folks we 
know and love from the community and mailing lists contribute to the 
issue. Read articles by Paul Dubois and Travis Oliphant for free online.

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Fwd: Problem with Tk-Backend

2007-04-25 Thread Thorsten Kranz

Hi everyone,

I'm new here and I have a question ( I guess as everybody who is new here
;-) ),

I'm having some strange problem with Matplotlib, using it in a Tkinter
application.

I create a  Canvas, a figure, subplot and then a toolbar. It works fine, but
only without the toolbar! When I want to add the toolbar, I get an error

File "./tkViewer.py", line 102, in setupGUI
   self.toolbar = NavigationToolbar2TkAgg( self.canvas, master )
 File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 537, in __init__
   NavigationToolbar2.__init__(self, canvas)
 File "/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py", line
1107, in __init__
   self._init_toolbar()
 File
"/usr/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py",
line 577, in _init_toolbar
   borderwidth=2)
 File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 2378, in __init__
   Widget.__init__(self, master, 'frame', cnf, {}, extra)
 File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1865, in __init__
   self.tk.call(
_tkinter.TclError: bad screen distance "500.0"

Here is the part my code:

   self.canvFrame = Frame(master)
   self.canvFrame.pack(side=TOP, fill=BOTH, expand=1)
   self.canvFrame2 = Frame(self.canvFrame)
   self.canvFrame2.pack(side=LEFT, fill=BOTH, expand=1)
   self.f = Figure(figsize=(5,4), dpi=100)
   self.a = self.f.add_subplot(111)
   self.subplAxis = self.f.get_axes()
   self.canvas = FigureCanvasTkAgg(self.f, master=self.canvFrame2)
   self.canvas.show()
   self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
   self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.canvFrame2)
   self.toolbar.update()
   self.canvas._tkcanvas.pack(side=TOP, fill=X, expand=1)


Master is a parameter passed to my method, which actually is set to Tk()

What did I get wrong? What is the problem? Thanks in advance...

Thorsten
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Fernando Perez
On 4/25/07, Andrew Straw <[EMAIL PROTECTED]> wrote:
> The May/June issue of Computing in Science and Engineering
> http://computer.org/cise: is out and has a Python theme. Many folks we
> know and love from the community and mailing lists contribute to the
> issue. Read articles by Paul Dubois and Travis Oliphant for free online.


Since authors are allowed by their publication policy to keep a
publicly available copy of their papers on their personal website,
here's the ipython one:

http://amath.colorado.edu/faculty/fperez/preprints/ipython-cise-final.pdf



Cheers,

f

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread John Hunter
On 4/25/07, Fernando Perez <[EMAIL PROTECTED]> wrote:
> Since authors are allowed by their publication policy to keep a
> publicly available copy of their papers on their personal website,
> here's the ipython one:

Didn't know that...  here's a link to my matplotlib article

http://nitace.bsd.uchicago.edu/misc/c3sci.pdf

It might be nice to create a scipy wiki page linking to these PDFs.

JDH

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Fernando Perez
On 4/25/07, John Hunter <[EMAIL PROTECTED]> wrote:
> On 4/25/07, Fernando Perez <[EMAIL PROTECTED]> wrote:
> > Since authors are allowed by their publication policy to keep a
> > publicly available copy of their papers on their personal website,
> > here's the ipython one:
>
> Didn't know that...  here's a link to my matplotlib article

I'm going by the language here:

http://www.ieee.org/web/publications/rights/policies.html

Specifically:

 When IEEE publishes the work, the author must replace the previous
electronic version of the accepted paper with either (1) the full
citation to the IEEE work or (2) the IEEE-published version, including
the IEEE copyright notice and full citation. Prior or revised versions
of the paper must not be represented as the published version.


This explicitly mentions author website redistribution,  as long as
the official IEEE version is used.

Unless I'm misreading the above, I think it's OK for us to keep such
copies in our personal sites.  We can link to them from the scipy
wiki, though I don't think it would be OK to /copy/ the PDFs to the
scipy wiki.

As always, IANAL and all that.

Cheers,

f

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Andrew Straw
(Off list...)

(Another g-mailer, huh? Soon they'll know everything about everyone...)

Thanks for that info re: online paper copies. I'm actually a week or two 
away from submitting a follow-up paper from my SciPy '06 talk to them... 
And submitting to a non-open-access journal was one issue. But this 
makes it... bearable.

Cannae make SciPy '07 :( Will be at a insect/robot flight conference in 
the Italian-speaking part of Switzerland! :)

-Andrew

Fernando Perez wrote:
> On 4/25/07, John Hunter <[EMAIL PROTECTED]> wrote:
>> On 4/25/07, Fernando Perez <[EMAIL PROTECTED]> wrote:
>> > Since authors are allowed by their publication policy to keep a
>> > publicly available copy of their papers on their personal website,
>> > here's the ipython one:
>>
>> Didn't know that...  here's a link to my matplotlib article
>
> I'm going by the language here:
>
> http://www.ieee.org/web/publications/rights/policies.html
>
> Specifically:
>
> When IEEE publishes the work, the author must replace the previous
> electronic version of the accepted paper with either (1) the full
> citation to the IEEE work or (2) the IEEE-published version, including
> the IEEE copyright notice and full citation. Prior or revised versions
> of the paper must not be represented as the published version.
>
>
> This explicitly mentions author website redistribution,  as long as
> the official IEEE version is used.
>
> Unless I'm misreading the above, I think it's OK for us to keep such
> copies in our personal sites.  We can link to them from the scipy
> wiki, though I don't think it would be OK to /copy/ the PDFs to the
> scipy wiki.
>
> As always, IANAL and all that.
>
> Cheers,
>
> f


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Andrew Straw
Andrew Straw wrote:
> (Off list...)
>   
Eek, well, not off-list! :)

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Christopher Barker
Fernando Perez wrote:
> This explicitly mentions author website redistribution,  as long as
> the official IEEE version is used.
> 
> Unless I'm misreading the above, I think it's OK for us to keep such
> copies in our personal sites.  We can link to them from the scipy
> wiki, though I don't think it would be OK to /copy/ the PDFs to the
> scipy wiki.

I assume you are referring to this:

""
D. Personal Servers. Authors and/or their companies shall have the right 
to post their IEEE-copyrighted material on their own servers without 
permission, provided that the server displays a prominent notice 
alerting readers to their obligations with respect to copyrighted 
material and that the posted work includes the IEEE copyright notice as 
shown in Section 8.1.9A above.
"""

IANAL either, but I'm not sure how they would define a "personal" 
server. Would a web page on a University server count, for instance? I"d 
think putting it on the Wiki would count. Key is that copyright is 
properly attributed.

I assume there is someone at IEEE that you could ask.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Fernando Perez
On 4/25/07, Christopher Barker <[EMAIL PROTECTED]> wrote:
> Fernando Perez wrote:
> > This explicitly mentions author website redistribution,  as long as
> > the official IEEE version is used.
> >
> > Unless I'm misreading the above, I think it's OK for us to keep such
> > copies in our personal sites.  We can link to them from the scipy
> > wiki, though I don't think it would be OK to /copy/ the PDFs to the
> > scipy wiki.
>
> I assume you are referring to this:
>
> ""
> D. Personal Servers. Authors and/or their companies shall have the right
> to post their IEEE-copyrighted material on their own servers without
> permission, provided that the server displays a prominent notice
> alerting readers to their obligations with respect to copyrighted
> material and that the posted work includes the IEEE copyright notice as
> shown in Section 8.1.9A above.
> """
>
> IANAL either, but I'm not sure how they would define a "personal"
> server. Would a web page on a University server count, for instance? I"d
> think putting it on the Wiki would count. Key is that copyright is
> properly attributed.
>
> I assume there is someone at IEEE that you could ask.

Well, I simply interpreted 'personal' as "my personal page, on my
institution's servers", while I worry that physically uploading it to
scipy's servers, which are owned by an external entity (Enthought)
might land them in trouble.  I may be overly cautious here, but I just
didn't want to take chances.

Cheers,

f

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Suresh Pillai
This is correct, and is standard for almost all publications I know.  You 
are allowed to publish the article on your own personal website (provided
you use the published version or explicitly list the copyrights), but 
nowhere else.

Cheers,
Suresh

On Wed, 25 Apr 2007, Fernando Perez wrote:

> Well, I simply interpreted 'personal' as "my personal page, on my
> institution's servers", while I worry that physically uploading it to
> scipy's servers, which are owned by an external entity (Enthought)
> might land them in trouble.  I may be overly cautious here, but I just
> didn't want to take chances.
>
> Cheers,

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Python issue of Computing in Science and Engineering available

2007-04-25 Thread Ryan Krauss
My CiSE article can be downloaded from here:

http://www.siue.edu/~rkrauss/python_stuff.html

Ryan

On 4/25/07, John Hunter <[EMAIL PROTECTED]> wrote:
> On 4/25/07, Fernando Perez <[EMAIL PROTECTED]> wrote:
> > Since authors are allowed by their publication policy to keep a
> > publicly available copy of their papers on their personal website,
> > here's the ipython one:
>
> Didn't know that...  here's a link to my matplotlib article
>
> http://nitace.bsd.uchicago.edu/misc/c3sci.pdf
>
> It might be nice to create a scipy wiki page linking to these PDFs.
>
> JDH
>
> -
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to highlight part of a matrix (or wash out the rest of it)

2007-04-25 Thread Michael Lerner
Hi,

I have a square matrix that I'm plotting with pcolormesh.  I want to
highlight certain parts of it.  For instance, I might want to
highlight rows and columns 4-20 and 67-80.  I can get the opposite of
what I want by doing something like

pylab.axvspan(4,20,fc='white',lw=0.,alpha=0.15)
pylab.axvspan(67,80,fc='white',lw=0.,alpha=0.15)
pylab.axhspan(4,20,fc='white',lw=0.,alpha=0.15)
pylab.axhspan(67,80,fc='white',lw=0.,alpha=0.15)

but that makes it look like the regions I want to highlight are washed
out.  I'd like the inverse, where I wash out everything else.  How can
I do this?

My first thought was that I might be able to do something with a mask,
where I could plot the data once, then plot it again with a
semitransparent white mask over the parts I didn't want to highlight.

Here's some sample code where I tried to do that (this time masking
out some easy-to-calculate part of the matrix):

#!/usr/bin/env python
import pylab as P
import numpy as N

plotter = P.pcolormesh
plotterargs = {P.imshow:{'interpolation':'nearest','origin':'lower'},
   P.pcolormesh:{}}

n = 10
data = N.zeros((n,n))
for i in range(n):
for j in range(n):
data[i,j] = i*j
plotter(data,vmin=0,vmax=n*n,**plotterargs[plotter])

cmap = P.cm.jet
cmap.set_bad('white',alpha=0.5)
mask = data < 16
data = N.ma.masked_where(mask,data)
plotter(data,cmap=cmap,vmin=0,vmax=n*n,**plotterargs[plotter])
P.show()



If you run it, you'll see that the masked part just ends up grey.
However, if you set plotter to P.imshow, it looks like it pretty much
does what I want.  So, I think I might be close to the answer.  Can
someone help me figure it out?

Thanks,

-michael

-- 
Biophysics Graduate Student
Carlson Lab, University of Michigan
http://www.umich.edu/~mlerner http://lernerclan.net
http://www.umich.edu/~mlerner http://lernerclan.net

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Newbie. Memory useage question

2007-04-25 Thread brett . mcsweeney
Thanks John, that works perfectly.

Best regards,
Brett McSweeney





On 4/23/07, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> I'm producing series of plots (spectograms) in a program loop using 
imshow
> and saving each plot to .png.  Even though I close() each plot after 
each
> savefig(...), the memory does not appear to be freed up, and the memory
> useage goes up and up as the program runs (and stalls the computer as it
> thrashes the page file).
>
> This is the essence of the code:
>
> for i in range(..):
> pylab.imshow(logPSDs[i]...)
> pylab.colorbar()
> pylab.savefig(plotName[i])
> pylab.close()

The following code does not appear to leak:

import matplotlib
matplotlib.use('Agg')
from matplotlib.cbook import report_memory
import matplotlib.numerix as nx
import pylab


for i in range(100):
print i, report_memory(i)
fig = pylab.figure(1)
X = nx.mlab.rand(100,100)
pylab.imshow(X)
pylab.colorbar()
pylab.savefig('_test%d'%i)
pylab.close(1)


Are you running your program in a GUI?  Eric points out there are some
leaks in the GUI canvases which we have not succeeded in tracking
down.  If you only want image generation, you can use an image backend
w/o leaks.  The one thing to be careful of is to make sure you are not
overplotting multiple images onto the same Axes, eg by clearing the
figure or axes if you are reusing it.

JDH




>
> Is there anything that I should be doing to stop this memory "wastage"?
> (The plots themselves are fantastic!)
>  UNITED GROUP
>  This email message is the property of United Group. The information in 
this
> email is confidential and may be legally privileged. It is intended 
solely
> for the addressee. Access to this email by anyone else is unauthorised. 
If
> you are not the intended recipient, you may not disclose, copy or 
distribute
> this email, nor take or omit to take any action in reliance on it. 
United
> Group accepts no liability for any damage caused by this email or any
> attachments due to viruses, interference, interception, corruption or
> unauthorised access.
>  If you have received this email in error, please notify United Group
> immediately by email to the sender's email address and delete this 
document.
>
> 
-
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__



UNITED GROUP
This email message is the property of United Group. The information in this 
email is confidential and may be legally privileged. It is intended solely for 
the addressee. Access to this email by anyone else is unauthorised. If you are 
not the intended recipient, you may not disclose, copy or distribute this 
email, nor take or omit to take any action in reliance on it. United Group 
accepts no liability for any damage caused by this email or any attachments due 
to viruses, interference, interception, corruption or unauthorised access.
If you have received this email in error, please notify United Group 
immediately by email to the sender's email address and delete this document.-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users