473,662 Members | 2,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

memory error with matplot

Hi,

I am using matplotlib with python to generate a bunch of charts. My
code works fine for a single iteration, which creates and saves 4
different charts. The trouble is that when I try to run it for the
entire set (about 200 items) it can run for 12 items at a time. On the
13th, I get an error from matplotlib that says it can't access data.
However, if I start the program at the point it failed before it works
fine and will create the charts for the next 12 before failing. I
assume that I am not closing the files properly somehow or otherwise
misallocating memory. I tried just reimporting pylab each iteration,
but that didn't help. This is the function that creates a chart:

#create and save the figure
def CreateFigure(st ate, facility, unit, SO2, increment, year, P99):
size = len(SO2)

#Create Plot
figure(1, figsize=(10,8))
bar(range(1, size+2), SO2, width=0.1, color='k')
grid(True)
xlim(0,size)
ylim(0, 1.1*SO2[-1])
ylabel('SO2 [lb/hr]')
heading = ConstructFigNam e(state, facility, unit, increment, year)
title(heading)

#set handles
xticklines = getp(gca(), 'xticklines')
xgridlines = getp(gca(), 'xgridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklines = getp(gca(), 'yticklines')

#set properties
setp(xticklines , visible=False)
setp(xgridlines , visible=False)
setp(xticklabel s, visible=False)
setp(yticklines , visible=False)

axhspan(P99, P99, lw=3, ec='r', fc='r')
ax = gca()
#P99 = str(P99)
P99 = '%0.1f' % P99
text(0.01, 0.95, '99th Percentile: '+P99+' lb/hr',
transform=ax.tr ansAxes)

figpath = ConstructFigPat h(state, facility, unit, increment, year)
savefig(figpath )
close()

Can you see the problem?

thanks,
-Lisa

Dec 5 '06 #1
1 4675
>>>>"lisa" == lisa engblom <li**********@g mail.comwrites:

lisaHi, I am using matplotlib with python to generate a bunch of
lisacharts. My code works fine for a single iteration, which
lisacreates and saves 4 different charts. The trouble is that
lisawhen I try to run it for the entire set (about 200 items) it
lisacan run for 12 items at a time. On the 13th, I get an error
lisafrom matplotlib that says it can't access data. However, if
lisaI start the program at the point it failed before it works
lisafine and will create the charts for the next 12 before
lisafailing. I assume that I am not closing the files properly
lisasomehow or otherwise misallocating memory. I tried just
lisareimporting pylab each iteration, but that didn't help.
lisaThis is the function that creates a chart:

There are a couple of things to try. First, on a long shot, does it
help to do

close(1)

instead if simply close(). I don't think it will but worth a try.

Second, I think there is a small leak in the tkcanvas, but not in
matplotlib proper. Do you need to display the graphs you are
creating, or do you merely want to save them? If the latter, simply
use the Agg backend

import matplotlib
matplotlib.use( 'Agg')

*before* you import pylab.

Finally, if you are still having troubles, post a complete,
free-standing, script to the matplotlib mailing list and we'll see if
we can replicate it.

You may also want to take a look at the FAQ on memory leaks:

http://matplotlib.sourceforge.net/faq.html#LEAKS

JDH
Dec 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4394
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with SharedMemAccess_Mutex_ctypes.py or SharedMemAccess_Mutex_win32all.py
1
4360
by: Attila.Rajmund.Nohl | last post by:
Hello! I'm using KAI C++ Compiler (KCC) Version 4.0d on Sparc Solaris 8 with Sun WorkShop 6 update 2 backend (KCC compiles C++ code to C than uses the Sun compiler to produce machine executables). When I run our program under purify to check for memory errors, I get the following interesting error messages: MSE: Memory segment error: * This is occurring while in:
6
2291
by: Andrzej | last post by:
Used to read newsgroup for answers, now have to ask for them as well. I have an application (C#, .NET 1.1) that connects to local db on MSDE 2000 SP3a (using ADO from MDAC 2.71) on one side and to a web service on the other (not relevant I guess). Some stored procedures consume xml produced by DataSet objects (values as elements) using OPENXML statements. The application should be distributed among users having also Win98. Established...
25
2369
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My memory profile shows that those instances survive 3 rounds of GC collections - it's not what I expected. In my real code, CMyClass occupies big amount of memory and they all share one stance of another class that I don't have enough memory hold...
4
5997
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over data from August or any prior month for that matter works fine which is why this is so weird. Note that June 2004 through today is stored in the same f_pageviews table. Nothing has changed on the server in the last couple of months. I upgraded...
1
1548
by: dug | last post by:
Hi, I would like to do some real time signal processing with a graphical display and I would like your advice as to what I should use. I would like to be able to view the results and to change parameters of some signal processing in 'real time'. Data is coming quite slowly in every 1-5 seconds and will consist of (x,y,t). I have been thinking about SciPy or matplot, but am not restricting
2
3653
by: Bigbadbradezee | last post by:
in matplot lib how do I generate two separate windows for separate plots. ie i have two contour plots i want to print out every time a program is run, but in separate windows. contour(array,origin='upper') axis((0,Lx+1,0,Ly+1)) grid(True) draw() and i want another separate window that uses contour again using a different array.
6
4153
by: tgnelson85 | last post by:
Hello, C question here (running on Linux, though there should be no platform specific code). After reading through a few examples, and following one in a book, for linked lists i thought i would try my own small program. The problem is, I seem to be having trouble with memory, i.e. sometimes my program will work and display the correct output, and sometimes it will not and display garbage (in a printf call) so i assume i have been using...
5
24705
by: kumarmdb2 | last post by:
Hi guys, For last few days we are getting out of private memory error. We have a development environment. We tried to figure out the problem but we believe that it might be related to the OS (I am new to Windows so not sure). We are currently bouncing the instance to overcome this error. This generally happen at the end of business day only (So maybe memory might be getting used up?). We have already increased the statement heap & ...
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.