Skip to content

Loading…

PGF/Tikz: savefig could not handle a filename #1137

Closed
sciunto opened this Issue · 1 comment

1 participant

@sciunto

Hi,

I'm very enthousiastic with the new PGF/Tikz support. Thanks for that!

Installed from the github (master) repository via https://aur.archlinux.org/packages.php?ID=54712, I could not use in
savefig(fname, dpi=None, facecolor='w', edgecolor='w',
orientation='portrait', papertype=None, format=None,
transparent=False, bbox_inches=None, pad_inches=0.1)

fname as "A string containing a path to a filename" if the pgf backend is loaded.

Short snippet to reproduce

plot(sin(linspace(10,20)), 'o')
savefig('a.pgf')

whereas it works for other formats.

This is the traceback

TypeError                                 Traceback (most recent call last)
<ipython-input-9-1fb1eacfdd2b> in <module>()
----> 1 plt.savefig('a.pgf')

/usr/lib/python3.2/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)
    473 def savefig(*args, **kwargs):
    474     fig = gcf()
--> 475     return fig.savefig(*args, **kwargs)
    476
    477 @docstring.copy_dedent(Figure.ginput)

/usr/lib/python3.2/site-packages/matplotlib/figure.py in savefig(self, *args, **kwargs)
   1266             kwargs.setdefault('edgecolor', rcParams['savefig.edgecolor'])
   1267
-> 1268         self.canvas.print_figure(*args, **kwargs)
   1269
   1270         if transparent:

/usr/lib/python3.2/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orienta
tion, format, **kwargs)
   2087                 orientation=orientation,
   2088                 bbox_inches_restore=_bbox_inches_restore,
-> 2089                 **kwargs)
   2090         finally:
   2091             if bbox_inches and restore_bbox:

/usr/lib/python3.2/site-packages/matplotlib/backend_bases.py in print_pgf(self, *args, **kwargs)
   1846         from .backends.backend_pgf import FigureCanvasPgf # lazy import
   1847         pgf = self.switch_backends(FigureCanvasPgf)
-> 1848         return pgf.print_pgf(*args, **kwargs)
   1849
   1850     def print_png(self, *args, **kwargs):

/usr/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py in print_pgf(self, filename, *args, **kwargs)
    672             writeln(fh, r"\pgfusepath{use as bounding box}")
    673
--> 674             renderer = RendererPgf(self.figure, fh)
    675             self.figure.draw(renderer)
    676

/usr/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py in __init__(self, figure, fh)
    356
    357         # get LatexManager instance
--> 358         self.latexManager = LatexManagerFactory.get_latex_manager()
    359
    360     def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):

/usr/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py in get_latex_manager()
    203             if rcParams.get("pgf.debug", False):
    204                 print("creating LatexManager")
--> 205             new_inst = LatexManager()
    206             LatexManagerFactory.previous_instance = new_inst
    207             return new_inst


/usr/lib/python3.2/site-packages/matplotlib/backends/backend_pgf.py in __init__(self)
    241                                   stdout=subprocess.PIPE,
    242                                   universal_newlines=True)
--> 243         stdout, stderr = latex.communicate(self.latex_header + latex_end)
    244         if latex.returncode != 0:
    245             raise LatexError("LaTeX returned an error, probably missing font or error in preamble:\n%s" % stdout)

/usr/lib/python3.2/subprocess.py in communicate(self, input)
    817             return (stdout, stderr)
    818 
--> 819         return self._communicate(input)
    820 
    821 

/usr/lib/python3.2/subprocess.py in _communicate(self, input)
   1423 
   1424             if _has_poll:
-> 1425                 stdout, stderr = self._communicate_with_poll(input)
   1426             else:
   1427                 stdout, stderr = self._communicate_with_select(input)

/usr/lib/python3.2/subprocess.py in _communicate_with_poll(self, input)
   1490                         chunk = input[input_offset : input_offset + _PIPE_BUF]
   1491                         try:
-> 1492                             input_offset += os.write(fd, chunk)
   1493                         except OSError as e:
   1494                             if e.errno == errno.EPIPE:

TypeError: 'str' does not support the buffer interface

@sciunto

oops, I just became aware of #1118

@sciunto sciunto closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.