Matplotlib - an odd problem

K

koranthala

Hi,
I am using Matplotlib with Django to display charts on the web page.
I am facing an odd problem in that, everytime I do a refresh on the
web page, the image darkens - and the text becomes little unreadable.
5/6 refreshes later, the text becomes completely unreadable.
Since I am using Django test server, the same process is being used.
i.e. every refresh does not create a new process. When I tried killing
the process, the image again cleared.
So I think it is sort of memory leak or a saved value which is messing
up something.
But I cannot seem to find the issue at all.

The code is as follows -

import pylab
from cStringIO import StringIO

def print_pie_chart(request):
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
data = [15,30,45, 10]
pylab.figure(1, figsize=(2,2))
ax = pylab.axes([0.1, 0.1, 0.8, 0.8])
pylab.pie(data, explode=None, labels=labels, autopct='%1.1f%%',
shadow=True)
out = StringIO()
pylab.savefig(out, format="PNG")
out.seek(0)
response = HttpResponse()
response['Content-Type'] = 'image/png'
response.write(out.read())
return response

Can anyone help me out here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top