Wednesday, August 1, 2012

Re: How to print a graph

On Wed, 1 Aug 2012 12:58:14 -0400, Peregil <peregilx@gmail.com>
declaimed the following in gmane.comp.python.django.user:

> a user to print one
>
> I did this in python, but throws an error in django when I tried to run
> it... I have seen some examples of saving an image, but I would like to
> avoid that since I don't want to open and close a file...
>
What error?
>
> xlable('Gene 1')
> ylable('Gene 2')

Don't type from memory -- if this is matplotlib those are xlabel and
ylabel. I'd expect xlable to produce an error.

>>> from matplotlib import *
>>> xlable("error")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'xlable' is not defined
>>> xlabel("okay")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'xlabel' is not defined
>>> from pylab import *
>>> xlable("error")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'xlable' is not defined
>>> xlabel("okay")
<matplotlib.text.Text object at 0x0253A7D0>
>>>


> show()

To my knowledge (again if this is matplotlib) this command tells it
to open a Tk (or whatever GUI library is configured) window to display
the plot. A web-server application likely doesn't have ANY display
device available to display a plot -- and if it did, the client sure
won't see it in their browser. Furthermore -- the program will block at
this point awaiting user input to the GUI window.

Configure for the Agg backend, and produce PNG image files which can
be sent as part of the page delivered to the client browser. Use
savefig() instead of show()



--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment