canvas.print_svg()

I get this error when using canvas.print_svg():

In [27]: canvas.print_svg(buffer)

···

<type ‘exceptions.NameError’> Traceback (most recent call last)

Z:<ipython console> in ()

C:\Python25\Lib\site-packages\matplotlib\backend_bases.py in print_svg(self, *ar
gs, **kwargs)
1124 from backends.backend_svg import FigureCanvasSVG # lazy import

1125 svg = self.switch_backends(FigureCanvasSVG)
-> 1126 return svg.print_svg(*args, **kwargs)
1127
1128 def print_svgz(self, *args, **kwargs):

C:\Python25\Lib\site-packages\matplotlib\backends\backend_svg.py in print_svg(se

lf, filename, *args, **kwargs)
463 if is_string_like(filename):
464 fh_to_close = svgwriter = codecs.open(filename, ‘w’, ‘utf-8’
)
–> 465 elif is_writable_file_like(filename):

466             svgwriter = codecs.EncodedFile(filename, 'utf-8')
467             fh_to_close = None

C:\Python25\Lib\site-packages\matplotlib\cbook.py in is_writable_file_like(obj)
215

216 def is_writable_file_like(obj):

–> 217 return hasattr(filename, ‘write’) and callable(filename.write)
218
219 def is_scalar(obj):

<type ‘exceptions.NameError’>: global name ‘filename’ is not defined

In [28]: canvas
Out[28]: <matplotlib.backends.backend_tkagg.FigureCanvasTkAgg instance at 0x01CA
EDF0>

It seems that
def is_writable_file_like(obj):

should be
def is_writable_file_like(filename):

Thanks. This has already been fixed in SVN, and should make it into the 0.91.2 release shortly.

Cheers,
Mike

Brandon Reno wrote:

···

I get this error when using canvas.print_svg():

In [27]: canvas.print_svg(buffer)
---------------------------------------------------------------------------
<type 'exceptions.NameError'> Traceback (most recent call last)

Z:\<ipython console> in <module>()

C:\Python25\Lib\site-packages\matplotlib\backend_bases.py in print_svg(self, *ar
gs, **kwargs)
   1124 from backends.backend_svg import FigureCanvasSVG # lazy import
   1125 svg = self.switch_backends(FigureCanvasSVG)
-> 1126 return svg.print_svg(*args, **kwargs)
   1127
   1128 def print_svgz(self, *args, **kwargs):

C:\Python25\Lib\site-packages\matplotlib\backends\backend_svg.py in print_svg(se
lf, filename, *args, **kwargs)
    463 if is_string_like(filename):
    464 fh_to_close = svgwriter = codecs.open(filename, 'w', 'utf-8'
)
--> 465 elif is_writable_file_like(filename):
    466 svgwriter = codecs.EncodedFile(filename, 'utf-8')
    467 fh_to_close = None

C:\Python25\Lib\site-packages\matplotlib\cbook.py in is_writable_file_like(obj)
    215
    216 def is_writable_file_like(obj):
--> 217 return hasattr(filename, 'write') and callable(filename.write)
    218
    219 def is_scalar(obj):

<type 'exceptions.NameError'>: global name 'filename' is not defined

In [28]: canvas
Out[28]: <matplotlib.backends.backend_tkagg.FigureCanvasTkAgg instance at 0x01CA
EDF0>

It seems that
def is_writable_file_like(obj):

should be
def is_writable_file_like(filename):

------------------------------------------------------------------------

-------------------------------------------------------------------------
SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA