matplotlib/matplotlib — Issue #603: PDF Backend bug?
Author: dmcdougall
Created: 2011-12-01 19:53:20+00:00
State: open

I seem to be getting a strange error when the PDF backend starts to render tex. Here's a minimal example illustrating the error:

from matplotlib.backends.backend_pdf import FigureCanvasPdf as FigureCanvas
from matplotlib.figure import Figure

fig = Figure()
canvas = FigureCanvas(fig)
ax = fig.gca()
ax.quiver([[1, 2], [3, 4]], [[-4, -3], [-2, -1]])
canvas.print_figure('sample')

The error I get is:

Traceback (most recent call last):
File "plot-samples.py", line 38, in
canvas.print_figure('sample')
File "/Users/damon/python/lib/matplotlib/backend_bases.py", line 2027, in print_figure
**kwargs)
File "/Users/damon/python/lib/matplotlib/backends/backend_pdf.py", line 2181, in print_pdf
self.figure.draw(renderer)
File "/Users/damon/python/lib/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/damon/python/lib/matplotlib/figure.py", line 886, in draw
func(*args)
File "/Users/damon/python/lib/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/damon/python/lib/matplotlib/axes.py", line 1983, in draw
a.draw(renderer)
File "/Users/damon/python/lib/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/damon/python/lib/matplotlib/axis.py", line 1045, in draw
tick.draw(renderer)
File "/Users/damon/python/lib/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/damon/python/lib/matplotlib/axis.py", line 239, in draw
self.label1.draw(renderer)
File "/Users/damon/python/lib/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/Users/damon/python/lib/matplotlib/text.py", line 567, in draw
self._fontproperties, angle)
File "/Users/damon/python/lib/matplotlib/backends/backend_pdf.py", line 1557, in draw_tex
page = next(iter(dvi))
UnboundLocalError: local variable 'next' referenced before assignment

FYI: I have usetex set to True in my matplotlibrc file.