'could not open display' errors plotting inside a CGI script

I know this matplotlib code works. I'm having trouble
running it in a CGI script. It appears some of modules
matplotlib imports need certain X Window permissions or
DISPLAY variable set?....

[seberino root /var/www] # tail /var/log/apache2/error.log
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1]
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] import gtk; gdk =
gtk.gdk
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] File
"/usr/lib/python2.3/site-packages/gtk-2.0/gtk/__init__.py", line 37,
in ?
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1]
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] from _gtk import *
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] RuntimeError
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] :
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] could not open
display
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1]
[Tue Feb 14 17:07:30 2006] [error] [client 127.0.0.1] Premature end of
script headers: create_ssg.py