SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S



1
(9)
2
(1)
3
(4)
4
(4)
5
(9)
6
(5)
7
(12)
8
(5)
9
(27)
10
(10)
11
(4)
12
13
(6)
14
(12)
15
(16)
16
(13)
17
(9)
18
(1)
19
(2)
20
(4)
21
(9)
22
(5)
23
(2)
24
(6)
25
26
(1)
27
(9)
28
(7)
29
(2)
30
(9)


Showing 12 results of 12

From: Russell E. O. <ro...@uw...> - 2011年06月16日 18:51:20
In article <BANLkTi=bj2...@ma...>,
 Rebecca Gray <atl...@gm...> wrote:
> I am trying to install matplotlib on my Mac OS X 10.6.6. I currently have
> Python 2.7.2 installed. I tried installing
> ***matplotlib-1.0.1-python.org-32bit-py2.7-macosx10.3.dmg.
> The installation appears to run fine, but when I try to import pylab * I am
> getting the following error message:
> 
> >>> from numpy import *
> >>> import pylab
>...
> ImportError:
> dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-pa
> ckages/matplotlib/_path.so,
> 2): no suitable image found. Did find:
> 
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
> matplotlib/_path.so:
> no matching architecture in universal wrapper
> 
> I am new to Python and any help would be greatly appreciated.
> 
> Thanks,
> 
> Rebecca
Which Python 2.7.2 are you using? The matplotlib installer is only 
compatible with the 32-bit version from python.org and I suspect you are 
using the 64-bit version or some other distribution entirely.
If you are definitely using the 32-bit python.org version then could you 
please execute the "file" command on _path.so?
When I do that for mine I get:
d-172-28-191-121:matplotlib rowen$ file _path.so
_path.so: Mach-O universal binary with 2 architectures
_path.so (for architecture ppc): Mach-O bundle ppc
_path.so (for architecture i386): Mach-O bundle i386
-- Russell
From: Eric F. <ef...@ha...> - 2011年06月16日 17:42:41
On 06/16/2011 04:31 AM, zb wrote:
> line 1245 of cbook.py is missing the windows platform. So windows cannot
> be tested.
>
In the development version of mpl it can (I added it--but too recently 
for it to have gotten into 1.0.1), provided you have the "tasklist" 
executable, which I think is a free download from Microsoft.
If you would like to try it, you could include the new version, below, 
in your test script.
Eric
def report_memory(i=0): # argument may go away
 'return the memory consumed by process'
 from subprocess import Popen, PIPE
 pid = os.getpid()
 if sys.platform=='sunos5':
 a2 = Popen('ps -p %d -o osz' % pid, shell=True,
 stdout=PIPE).stdout.readlines()
 mem = int(a2[-1].strip())
 elif sys.platform.startswith('linux'):
 a2 = Popen('ps -p %d -o rss,sz' % pid, shell=True,
 stdout=PIPE).stdout.readlines()
 mem = int(a2[1].split()[1])
 elif sys.platform.startswith('darwin'):
 a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
 stdout=PIPE).stdout.readlines()
 mem = int(a2[1].split()[0])
 elif sys.platform.startswith('win'):
 try:
 a2 = Popen(["tasklist", "/nh", "/fi", "pid eq %d" % pid],
 stdout=PIPE).stdout.read()
 except OSError:
 raise NotImplementedError(
 "report_memory works on Windows only if "
 "the 'tasklist' program is found")
 mem = int(a2.strip().split()[-2].replace(',',''))
 else:
 raise NotImplementedError(
 "We don't have a memory monitor for %s" % sys.platform)
 return mem
From: stefanie <lu...@go...> - 2011年06月16日 15:47:55
Hello!
I'm plotting the river danube and some other stuff around it. Is there
an easy way to extract several rectangles around the river and plot this
rectangles next to each other? My aim is to print the whole river on a
paper. My idea is to cut a rectangle every 100km, turn it straight (but
marking North) and put all rectangles next/under each other. Or should I
plot everything and continue with an image library?
Any help is appreciated!
Kind regards
Stefanie
From: Alain F. <fra...@it...> - 2011年06月16日 14:47:47
Hi Jakob,
yes your solution works and is more elegant! See the code at the end of this
message.
However using the original code with the Agg backend instead of WXAgg also
works fine, so there is probably a memory leakage problem with WXAgg (see
the post of David and my reply).
Thank for your reply and suggestion!
Alain
CODE
# BOF
import os, tempfile
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
print '\nBackend:\n' + mpl.get_backend() + '\n'
def plot_density(filename,i,t,psi_Na, fig):
 plt.imshow(abs(psi_Na)**2,origin = 'lower')
 filename = os.path.join(tempfile.gettempdir(), filename + '_%04d.png'%i)
 plt.savefig(filename)
 plt.clf()
if __name__ == "__main__":
 x = np.linspace(-6e-6,6e-6,128,endpoint=False)
 y = np.linspace(-6e-6,6e-6,128,endpoint=False)
 X,Y = np.meshgrid(x,y)
 k = 1000000
 omega = 200
 times = np.linspace(0,100e-3,100,endpoint=False)
 fig = plt.figure(figsize=(8,6))
 for i,t in enumerate(times):
 psi_Na = np.sin(k*X-omega*t)
 plot_density('wavefunction',i,t,psi_Na, fig)
 print i
 plt.close()
# EOF
Jakob Gager wrote:
> 
> Hi,
> 
> I'm not sure if it helps, but you can try to plot always into the same 
> figure object instead of creating a new one every time you call the 
> plot_density function.
> 
> I would create one figure in advance and pass this the plot_density 
> method. Within the method set the figure active (pl.figure(fig.number)), 
> plot the data, save the figure and clear the figure canvas (pl.clf() 
> should work here, I guess).
> Well, as mentioned I'm not sure but you could give it a try.
> 
> br
> Jakob
> 
> Alain Francés wrote:
>> Hi, http://old.nabble.com/file/p31858795/ErrorMsg.png 
>> 
>> indeed I forgot to remove these line from previous tests, sorry.
>> 
>> However it doesn't affect the code behaviour, the problem remains (it
>> fills
>> the RAM memory and raises a memory error, see img in att.).
>> 
>> Alain 
>> 
>> 
>> Davidmh wrote:
>>> You are importing pylab again before each plot. You have loaded it
>>> before.
>>>
>>> for i,t in enumerate(times):
>>> import pylab as pl # <--ERASE THIS
>>>
>>>
>>>
>>> On Wed, Jun 15, 2011 at 12:10 PM, Alain Pascal Frances
>>> <fra...@it...> wrote:
>>>> Hi,
>>>>
>>>> I have a script that creates and saves figures in a loop. The memory is
>>>> increasing at each figure and is not released back, rising a Memory
>>>> error.
>>>> I used the close() function on the figure object as well as
>>>> gc.collect(),
>>>> but no effect.
>>>>
>>>> I searched on the net and found a similar problem at
>>>> http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
>>>> The problem here was solved using the close() function but in my case,
>>>> as
>>>> refered before, it doens't work (see code below).
>>>>
>>>> I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on
>>>> windows7.
>>>>
>>>> Thanks for help!
>>>>
>>>> Alain
>>>>
>>>>
>>>> CODE:
>>>>
>>>> import pylab as pl
>>>> import os, tempfile
>>>> def plot_density(filename,i,t,psi_Na):
>>>> pl.figure(figsize=(8,6))
>>>> pl.imshow(abs(psi_Na)**2,origin = 'lower')
>>>> filename = os.path.join(tempfile.gettempdir(), filename +
>>>> '_%04d.png'%i)
>>>> pl.savefig(filename)
>>>> pl.clf()
>>>> pl.close()
>>>> if __name__ == "__main__":
>>>> x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>> y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>> X,Y = pl.meshgrid(x,y)
>>>> k = 1000000
>>>> omega = 200
>>>> times = pl.linspace(0,100e-3,100,endpoint=False)
>>>> for i,t in enumerate(times):
>>>> import pylab as pl
>>>> psi_Na = pl.sin(k*X-omega*t)
>>>> plot_density('wavefunction',i,t,psi_Na)
>>>> print i
>>>> ------------------------------------------------------------------------------
> 
> 
> 
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Memory-increasing-while-plotting-in-loop-tp31850163p31861342.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Alain F. <fra...@it...> - 2011年06月16日 14:37:41
Hi,
I'm using WXAgg by default because I developped an application with GUI
using wxpython.
But in this case indeed I don't need WXAgg and substituting WXAgg by Agg
just work fine, both in the code I submitted as example (see the corrected
code at the end) and in the one I'm working with.
So yes, probably there is a memory leakage using WXAgg that, as you say, can
be an interesting problem for the experts!
Thank you very much for your wise solution (if you are interested, see also
the comment of Jakob and my reply, he proposed an elegant solution still
using WXAgg).
Alain
CORRECTED CODE:
# BOF
import os, tempfile
import matplotlib as mpl
if mpl.get_backend<>'agg':
 mpl.use('agg')
import matplotlib.pyplot as plt
import numpy as np
print '\nBackend:\n' + mpl.get_backend() + '\n'
def plot_density(filename,i,t,psi_Na):
 plt.figure(figsize=(8,6))
 plt.imshow(abs(psi_Na)**2,origin = 'lower')
 filename = os.path.join(tempfile.gettempdir(), filename + '_%04d.png'%i)
 plt.savefig(filename)
 plt.close()
if __name__ == "__main__":
 x = np.linspace(-6e-6,6e-6,128,endpoint=False)
 y = np.linspace(-6e-6,6e-6,128,endpoint=False)
 X,Y = np.meshgrid(x,y)
 k = 1000000
 omega = 200
 times = np.linspace(0,100e-3,500,endpoint=False)
 for i,t in enumerate(times):
 psi_Na = np.sin(k*X-omega*t)
 plot_density('wavefunction',i,t,psi_Na)
 print i
# EOF
Davidmh wrote:
> 
> I can run the script you provided up to 600 without noticing any
> memory growth (TkAgg backend by default). Using the WxAgg, the memory
> leak appears.
> 
> If you don't explicitly need WxAgg, I would recommend using TkAgg, or
> better Agg if you are not showing the figures. If it is not the case,
> more expert and wiser people will have to come to help.
> 
> 
> On Thu, Jun 16, 2011 at 11:41 AM, Alain Francés <fra...@it...>
> wrote:
>>
>> Hi, http://old.nabble.com/file/p31858795/ErrorMsg.png
>>
>> indeed I forgot to remove these line from previous tests, sorry.
>>
>> However it doesn't affect the code behaviour, the problem remains (it
>> fills
>> the RAM memory and raises a memory error, see img in att.).
>>
>> Alain
>>
>>
>> Davidmh wrote:
>>>
>>> You are importing pylab again before each plot. You have loaded it
>>> before.
>>>
>>> for i,t in enumerate(times):
>>>    import pylab as pl # <--ERASE THIS
>>>
>>>
>>>
>>> On Wed, Jun 15, 2011 at 12:10 PM, Alain Pascal Frances
>>> <fra...@it...> wrote:
>>>> Hi,
>>>>
>>>> I have a script that creates and saves figures in a loop. The memory is
>>>> increasing at each figure and is not released back, rising a Memory
>>>> error.
>>>> I used the close() function on the figure object as well as
>>>> gc.collect(),
>>>> but no effect.
>>>>
>>>> I searched on the net and found a similar problem at
>>>> http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
>>>> The problem here was solved using the close() function but in my case,
>>>> as
>>>> refered before, it doens't work (see code below).
>>>>
>>>> I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on
>>>> windows7.
>>>>
>>>> Thanks for help!
>>>>
>>>> Alain
>>>>
>>>>
>>>> CODE:
>>>>
>>>> import pylab as pl
>>>> import os, tempfile
>>>> def plot_density(filename,i,t,psi_Na):
>>>>  pl.figure(figsize=(8,6))
>>>>  pl.imshow(abs(psi_Na)**2,origin = 'lower')
>>>>  filename = os.path.join(tempfile.gettempdir(), filename +
>>>> '_%04d.png'%i)
>>>>  pl.savefig(filename)
>>>>  pl.clf()
>>>>  pl.close()
>>>> if __name__ == "__main__":
>>>>  x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>>  y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>>  X,Y = pl.meshgrid(x,y)
>>>>  k = 1000000
>>>>  omega = 200
>>>>  times = pl.linspace(0,100e-3,100,endpoint=False)
>>>>  for i,t in enumerate(times):
>>>>    import pylab as pl
>>>>    psi_Na = pl.sin(k*X-omega*t)
>>>>    plot_density('wavefunction',i,t,psi_Na)
>>>>    print i
>>>> ------------------------------------------------------------------------------
>>>> EditLive Enterprise is the world's most technically advanced content
>>>> authoring tool. Experience the power of Track Changes, Inline Image
>>>> Editing and ensure content is compliant with Accessibility Checking.
>>>> http://p.sf.net/sfu/ephox-dev2dev
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> EditLive Enterprise is the world's most technically advanced content
>>> authoring tool. Experience the power of Track Changes, Inline Image
>>> Editing and ensure content is compliant with Accessibility Checking.
>>> http://p.sf.net/sfu/ephox-dev2dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Memory-increasing-while-plotting-in-loop-tp31850163p31858795.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> EditLive Enterprise is the world's most technically advanced content
>> authoring tool. Experience the power of Track Changes, Inline Image
>> Editing and ensure content is compliant with Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Memory-increasing-while-plotting-in-loop-tp31850163p31861233.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: zb <za...@ya...> - 2011年06月16日 14:31:41
line 1245 of cbook.py is missing the windows platform. So windows cannot be tested.
def report_memory(i=0): # argument may go away
  'return the memory consumed by process'
  from subprocess import Popen, PIPE
  pid = os.getpid()
  if sys.platform=='sunos5':
    a2 = Popen('ps -p %d -o osz' % pid, shell=True,
      stdout=PIPE).stdout.readlines()
    mem = int(a2[-1].strip())
  elif sys.platform.startswith('linux'):
    a2 = Popen('ps -p %d -o rss,sz' % pid, shell=True,
      stdout=PIPE).stdout.readlines()
    mem = int(a2[1].split()[1])
  elif sys.platform.startswith('darwin'):
    a2 = Popen('ps -p %d -o rss,vsz' % pid, shell=True,
      stdout=PIPE).stdout.readlines()
    mem = int(a2[1].split()[0])
  return mem
--- On Thu, 6/16/11, zb <za...@ya...> wrote:
From: zb <za...@ya...>
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
To: "Eric Firing" <ef...@ha...>, mat...@li...
Date: Thursday, June 16, 2011, 10:15 AM
Hi.
Sorry but that program does not even run. I am using
matplotlib-1.0.1.win32-py2.6.exe
It breaks with the error (I had to modified a little to get the full error):
UnboundLocalError: local variable 'mem' referenced before assignment
Traceback (most recent call last):
File...
File "C:\Python26\lib\site-packages\matplotlib\cbook.py", line 1245, in report_memory
  return mem
Looks like you are using a different matplotlib version.
Cheers
--- On Wed, 6/15/11, Eric Firing <ef...@ha...> wrote:
From: Eric Firing <ef...@ha...>
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
To:
 mat...@li...
Date: Wednesday, June 15, 2011, 7:46 PM
On 06/15/2011 01:15 PM, zb wrote:
> Hi
>
> You could try the example here:
>
> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt4.html
>
> Look at the memory grow. It does the same in my program.
I added a call to cbook.report_memory, and shortened the timer to 0.1 
seconds in the attached version.
There is no memory leakage evident when I run this on my system.
Eric
>
> Cheers
>
> --- On *Wed, 6/15/11, Eric Firing /<ef...@ha...>/* wrote:
>
>
>   From: Eric Firing <ef...@ha...>
>   Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
>   To: mat...@li...
>   Date: Wednesday, June 15, 2011, 6:33 PM
>
>   On 06/15/2011 12:13 PM, zb wrote:
>   > Hi
>   >
>   > I have a loop that updates a graph by calling
>   >
>   > self.fig.canvas.draw()
>   >
>   > But every time it updates the graph, the memory usage goes up. If the
>   > program runs
 for one hour, the memory is gone (things start to
>   run slow
>   > too). I've tried to close() objects but the only thing that
>   brings back
>   > the ram memory is to close the whole application.
>   >
>   > I have read this note in the documentation (but it applies to
>   pyplot):
>   >
>   > "If you are making a long sequence of figures, you need to be
>   aware of
>   > one more thing: the memory requiredfor a figure is not completely
>   > released until the figure is explicitly closed with close(). Deleting
>   > all references to the figure, and/or using the window manager to kill
> 
   > the window in which the figure appears on the screen, is not enough,
>   > because pyplot maintains internal references until close() is
>   called."
>   >
>   > What could I do in pyqt4 to release the memory?
>   >
>   > Thanks
>
>   Please provide a simple standalone script that demonstrates the problem.
>
>   Eric
>
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
-----Inline Attachment Follows-----
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
-----Inline Attachment Follows-----
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: zb <za...@ya...> - 2011年06月16日 14:15:35
Hi.
Sorry but that program does not even run. I am using
matplotlib-1.0.1.win32-py2.6.exe
It breaks with the error (I had to modified a little to get the full error):
UnboundLocalError: local variable 'mem' referenced before assignment
Traceback (most recent call last):
File...
File "C:\Python26\lib\site-packages\matplotlib\cbook.py", line 1245, in report_memory
  return mem
Looks like you are using a different matplotlib version.
Cheers
--- On Wed, 6/15/11, Eric Firing <ef...@ha...> wrote:
From: Eric Firing <ef...@ha...>
Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
To: mat...@li...
Date: Wednesday, June 15, 2011, 7:46 PM
On 06/15/2011 01:15 PM, zb wrote:
> Hi
>
> You could try the example here:
>
> http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt4.html
>
> Look at the memory grow. It does the same in my program.
I added a call to cbook.report_memory, and shortened the timer to 0.1 
seconds in the attached version.
There is no memory leakage evident when I run this on my system.
Eric
>
> Cheers
>
> --- On *Wed, 6/15/11, Eric Firing /<ef...@ha...>/* wrote:
>
>
>   From: Eric Firing <ef...@ha...>
>   Subject: Re: [Matplotlib-users] canvas.draw() + pyqt4 memory leak
>   To: mat...@li...
>   Date: Wednesday, June 15, 2011, 6:33 PM
>
>   On 06/15/2011 12:13 PM, zb wrote:
>   > Hi
>   >
>   > I have a loop that updates a graph by calling
>   >
>   > self.fig.canvas.draw()
>   >
>   > But every time it updates the graph, the memory usage goes up. If the
>   > program runs for one hour, the memory is gone (things start to
>   run slow
>   > too). I've tried to close() objects but the only thing that
>   brings back
>   > the ram memory is to close the whole application.
>   >
>   > I have read this note in the documentation (but it applies to
>   pyplot):
>   >
>   > "If you are making a long sequence of figures, you need to be
>   aware of
>   > one more thing: the memory requiredfor a figure is not completely
>   > released until the figure is explicitly closed with close(). Deleting
>   > all references to the figure, and/or using the window manager to kill
>   > the window in which the figure appears on the screen, is not enough,
>   > because pyplot maintains internal references until close() is
>   called."
>   >
>   > What could I do in pyqt4 to release the memory?
>   >
>   > Thanks
>
>   Please provide a simple standalone script that demonstrates the problem.
>
>   Eric
>
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
-----Inline Attachment Follows-----
_______________________________________________
Matplotlib-users mailing list
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jae-Joon L. <lee...@gm...> - 2011年06月16日 12:21:45
On Tue, Jun 14, 2011 at 4:58 AM, Nicholas Devenish
<mis...@gm...> wrote:
> Is there a way I can avoid or correct this behaviour? It certainly
> seems erroneous that using the figure GUI to adjust plot bounds
> doesn't work, and is an especially nice way of tweaking for final
> plots.
>
Unfortunately no.
This is a limitation of how colobar is currently implemented (v1.1
will have a workaround to this).
I think the simple (but may not be good enough) workaround is to call
"colorbar" after subplot adjusting is done.
Alternatively, you may try the axes_grid1 toolkit.
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#colorbar-whose-height-or-width-in-sync-with-the-master-axes
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2011年06月16日 12:11:21
Thanks.
I fixed it in in the master branch.
https://github.com/matplotlib/matplotlib/commit/649df91f8e0bb77687be0711d64201904bcdde67
Regards,
-JJ
On Wed, Jun 15, 2011 at 7:04 AM, Uri Laserson <las...@mi...> wrote:
> In the Legend Guide:
> http://matplotlib.sourceforge.net/users/legend_guide.html
> it gives a list of artists that the legend can handle (e.g., Line2D, Patch,
> etc.). However, it leaves out CircleCollection.
> Best,
> Uri
>
> ...................................................................................
> Uri Laserson
> Graduate Student, Biomedical Engineering
> Harvard-MIT Division of Health Sciences and Technology
> M +1 917 742 8019
> las...@mi...
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Daπid <dav...@gm...> - 2011年06月16日 11:15:59
I can run the script you provided up to 600 without noticing any
memory growth (TkAgg backend by default). Using the WxAgg, the memory
leak appears.
If you don't explicitly need WxAgg, I would recommend using TkAgg, or
better Agg if you are not showing the figures. If it is not the case,
more expert and wiser people will have to come to help.
On Thu, Jun 16, 2011 at 11:41 AM, Alain Francés <fra...@it...> wrote:
>
> Hi, http://old.nabble.com/file/p31858795/ErrorMsg.png
>
> indeed I forgot to remove these line from previous tests, sorry.
>
> However it doesn't affect the code behaviour, the problem remains (it fills
> the RAM memory and raises a memory error, see img in att.).
>
> Alain
>
>
> Davidmh wrote:
>>
>> You are importing pylab again before each plot. You have loaded it before.
>>
>> for i,t in enumerate(times):
>>    import pylab as pl # <--ERASE THIS
>>
>>
>>
>> On Wed, Jun 15, 2011 at 12:10 PM, Alain Pascal Frances
>> <fra...@it...> wrote:
>>> Hi,
>>>
>>> I have a script that creates and saves figures in a loop. The memory is
>>> increasing at each figure and is not released back, rising a Memory
>>> error.
>>> I used the close() function on the figure object as well as gc.collect(),
>>> but no effect.
>>>
>>> I searched on the net and found a similar problem at
>>> http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
>>> The problem here was solved using the close() function but in my case, as
>>> refered before, it doens't work (see code below).
>>>
>>> I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on windows7.
>>>
>>> Thanks for help!
>>>
>>> Alain
>>>
>>>
>>> CODE:
>>>
>>> import pylab as pl
>>> import os, tempfile
>>> def plot_density(filename,i,t,psi_Na):
>>>  pl.figure(figsize=(8,6))
>>>  pl.imshow(abs(psi_Na)**2,origin = 'lower')
>>>  filename = os.path.join(tempfile.gettempdir(), filename +
>>> '_%04d.png'%i)
>>>  pl.savefig(filename)
>>>  pl.clf()
>>>  pl.close()
>>> if __name__ == "__main__":
>>>  x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>  y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>>  X,Y = pl.meshgrid(x,y)
>>>  k = 1000000
>>>  omega = 200
>>>  times = pl.linspace(0,100e-3,100,endpoint=False)
>>>  for i,t in enumerate(times):
>>>    import pylab as pl
>>>    psi_Na = pl.sin(k*X-omega*t)
>>>    plot_density('wavefunction',i,t,psi_Na)
>>>    print i
>>> ------------------------------------------------------------------------------
>>> EditLive Enterprise is the world's most technically advanced content
>>> authoring tool. Experience the power of Track Changes, Inline Image
>>> Editing and ensure content is compliant with Accessibility Checking.
>>> http://p.sf.net/sfu/ephox-dev2dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>> ------------------------------------------------------------------------------
>> EditLive Enterprise is the world's most technically advanced content
>> authoring tool. Experience the power of Track Changes, Inline Image
>> Editing and ensure content is compliant with Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Memory-increasing-while-plotting-in-loop-tp31850163p31858795.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jakob G. <ga...@il...> - 2011年06月16日 10:51:37
Hi,
I'm not sure if it helps, but you can try to plot always into the same 
figure object instead of creating a new one every time you call the 
plot_density function.
I would create one figure in advance and pass this the plot_density 
method. Within the method set the figure active (pl.figure(fig.number)), 
plot the data, save the figure and clear the figure canvas (pl.clf() 
should work here, I guess).
Well, as mentioned I'm not sure but you could give it a try.
br
Jakob
Alain Francés wrote:
> Hi, http://old.nabble.com/file/p31858795/ErrorMsg.png 
> 
> indeed I forgot to remove these line from previous tests, sorry.
> 
> However it doesn't affect the code behaviour, the problem remains (it fills
> the RAM memory and raises a memory error, see img in att.).
> 
> Alain 
> 
> 
> Davidmh wrote:
>> You are importing pylab again before each plot. You have loaded it before.
>>
>> for i,t in enumerate(times):
>> import pylab as pl # <--ERASE THIS
>>
>>
>>
>> On Wed, Jun 15, 2011 at 12:10 PM, Alain Pascal Frances
>> <fra...@it...> wrote:
>>> Hi,
>>>
>>> I have a script that creates and saves figures in a loop. The memory is
>>> increasing at each figure and is not released back, rising a Memory
>>> error.
>>> I used the close() function on the figure object as well as gc.collect(),
>>> but no effect.
>>>
>>> I searched on the net and found a similar problem at
>>> http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
>>> The problem here was solved using the close() function but in my case, as
>>> refered before, it doens't work (see code below).
>>>
>>> I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on windows7.
>>>
>>> Thanks for help!
>>>
>>> Alain
>>>
>>>
>>> CODE:
>>>
>>> import pylab as pl
>>> import os, tempfile
>>> def plot_density(filename,i,t,psi_Na):
>>> pl.figure(figsize=(8,6))
>>> pl.imshow(abs(psi_Na)**2,origin = 'lower')
>>> filename = os.path.join(tempfile.gettempdir(), filename +
>>> '_%04d.png'%i)
>>> pl.savefig(filename)
>>> pl.clf()
>>> pl.close()
>>> if __name__ == "__main__":
>>> x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>> y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>> X,Y = pl.meshgrid(x,y)
>>> k = 1000000
>>> omega = 200
>>> times = pl.linspace(0,100e-3,100,endpoint=False)
>>> for i,t in enumerate(times):
>>> import pylab as pl
>>> psi_Na = pl.sin(k*X-omega*t)
>>> plot_density('wavefunction',i,t,psi_Na)
>>> print i
>>> ------------------------------------------------------------------------------
From: Alain F. <fra...@it...> - 2011年06月16日 09:41:34
Hi, http://old.nabble.com/file/p31858795/ErrorMsg.png 
indeed I forgot to remove these line from previous tests, sorry.
However it doesn't affect the code behaviour, the problem remains (it fills
the RAM memory and raises a memory error, see img in att.).
Alain 
Davidmh wrote:
> 
> You are importing pylab again before each plot. You have loaded it before.
> 
> for i,t in enumerate(times):
> import pylab as pl # <--ERASE THIS
> 
> 
> 
> On Wed, Jun 15, 2011 at 12:10 PM, Alain Pascal Frances
> <fra...@it...> wrote:
>> Hi,
>>
>> I have a script that creates and saves figures in a loop. The memory is
>> increasing at each figure and is not released back, rising a Memory
>> error.
>> I used the close() function on the figure object as well as gc.collect(),
>> but no effect.
>>
>> I searched on the net and found a similar problem at
>> http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
>> The problem here was solved using the close() function but in my case, as
>> refered before, it doens't work (see code below).
>>
>> I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on windows7.
>>
>> Thanks for help!
>>
>> Alain
>>
>>
>> CODE:
>>
>> import pylab as pl
>> import os, tempfile
>> def plot_density(filename,i,t,psi_Na):
>>  pl.figure(figsize=(8,6))
>>  pl.imshow(abs(psi_Na)**2,origin = 'lower')
>>  filename = os.path.join(tempfile.gettempdir(), filename +
>> '_%04d.png'%i)
>>  pl.savefig(filename)
>>  pl.clf()
>>  pl.close()
>> if __name__ == "__main__":
>>  x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>  y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
>>  X,Y = pl.meshgrid(x,y)
>>  k = 1000000
>>  omega = 200
>>  times = pl.linspace(0,100e-3,100,endpoint=False)
>>  for i,t in enumerate(times):
>>    import pylab as pl
>>    psi_Na = pl.sin(k*X-omega*t)
>>    plot_density('wavefunction',i,t,psi_Na)
>>    print i
>> ------------------------------------------------------------------------------
>> EditLive Enterprise is the world's most technically advanced content
>> authoring tool. Experience the power of Track Changes, Inline Image
>> Editing and ensure content is compliant with Accessibility Checking.
>> http://p.sf.net/sfu/ephox-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Memory-increasing-while-plotting-in-loop-tp31850163p31858795.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
1 message has been excluded from this view by a project administrator.

Showing 12 results of 12

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /