Skip to content

PGF back-end fails on simple graph #1128

Closed
@jholewinski

Description

@jholewinski

I'm not sure if this is related to the other Unicode/codec issue, but I'm trying out the pgf backend and I'm seeing what appears to be an issue with Unicode/codecs using matplotlib git master and Python 2.7 (Ubuntu 12.04):

jholewinski@rapture [tests]$ python t1.py 
Traceback (most recent call last):
  File "t1.py", line 14, in <module>
    fig.savefig('ti.pgf', bbox_inches='tight')
  File "/home/jholewinski/projects/matplotlib/matplotlib-pgf/build/lib.linux-x86_64-2.7/matplotlib/figure.py", line 1262, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/home/jholewinski/projects/matplotlib/matplotlib-pgf/build/lib.linux-x86_64-2.7/matplotlib/backend_bases.py", line 2048, in print_figure
    **kwargs)
  File "/home/jholewinski/projects/matplotlib/matplotlib-pgf/build/lib.linux-x86_64-2.7/matplotlib/backend_bases.py", line 1848, in print_pgf
    return pgf.print_pgf(*args, **kwargs)
  File "/home/jholewinski/projects/matplotlib/matplotlib-pgf/build/lib.linux-x86_64-2.7/matplotlib/backends/backend_pgf.py", line 664, in print_pgf
    with codecs.open(filename, "w", encoding="utf-8") as fh:
  File "/usr/lib/python2.7/codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
TypeError: coercing to Unicode: need string or buffer, _io.BytesIO found

The graph script is very basic:

import matplotlib as mpl
import matplotlib.pyplot as plt

fig = plt.figure()

sub = fig.add_subplot(1, 1, 1)

sub.plot([1, 2, 3], [2, 3, 4], label='Foo', markersize=2, marker='x')

sub.grid()
sub.set_axisbelow(True)
sub.legend(loc=2)

fig.savefig('t1.pgf', bbox_inches='tight')

I just built the latest git master with "python setup.py build" and used it directly from the build/ directory. Interestingly, the tests included with matplotlib do seem to generate graphs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions