Hi Derek,

I face same issue few months ago, what I did is I destroyed plot object
completely everytime the view is called and regenerated new plot everytime.
You can try that. There is an issue with matplotlib memory, which basically
usage same plot.

Another solution could be try different cStringIO to store base64 encoded
image data, send that as response and at browser using javascript (
data:image/png;base64).



Thanks,
With Best Regards,

Mitesh Patel

Senior Product Engineer

Mobile: +91-9970 8575 39
Email: mitesh.patel1...@gmail.com
LinkedIn : http://in.linkedin.com/in/miteshpatel11


On 18 January 2015 at 19:23, Derek <gamesb...@gmail.com> wrote:

> I have a situation which is puzzling.
>
> I have a web page that, when generated embeds links that look like:
>
> </div><img src="/analysis/design/chart?field=A></div>
> </div><img src="/analysis/design/chart?field=B></div>
> </div><img src="/analysis/design/chart?field=C></div>
>
> Each of these links points to a view that, when activated, creates a small
> PNG image (matplotlib is used for this) which is returned via an
> InMemoryUploadedFile object.
>
> The basic logic and image construction works - if each of these links is
> called directly from the browser, then each is created perfectly.
>
> However, when embedded in a single page (as above) then only one single
> image is returned and the rest generate a similar error:
>
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/pyplot.py",
> line 1401, in xlabel
>     l =  gca().set_xlabel(s, *args, **kwargs)
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/pyplot.py",
> line 803, in gca
>     ax =  gcf().gca(**kwargs)
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/figure.py",
> line 1221, in gca
>     return self.add_subplot(1, 1, 1, **kwargs)
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/figure.py",
> line 916, in add_subplot
>     self._axstack.add(key, a)
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/figure.py",
> line 120, in add
>     Stack.remove(self, (key, a_existing))
>   File
> "/home/gamesbook/.virtualenvs/dev/local/lib/python2.7/site-packages/matplotlib/cbook.py",
> line 1343, in remove
>     raise ValueError('Unknown element o')
> ValueError: Unknown element o
>
> I have googled for this error, but it seems fairly obscure and I am not
> sure how it relates to my situation.
>
> Any insights welcome!
>
> Thanks
> Derek
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF1Wu3OfN9rmUKTDO%2BT%3DJan%3DF%3DLKODqQObds-tvME%3DUhL18fMw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAF1Wu3OfN9rmUKTDO%2BT%3DJan%3DF%3DLKODqQObds-tvME%3DUhL18fMw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD3RGrQWey-Yi2W-Qkc8JynCtBgqxQhv8f3rdH8%3DPZ2AsHT_Rg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to