Skip to content

matplotlib 1.3.1 for Python 3.2.5 on Mac OS X produces corrupt .eps files #2748

Closed
@adamfreese

Description

@adamfreese

This is a problem if I have usetex=True. A simple script that produces the error is

import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
mpl.rc('text', usetex=True)
x = np.linspace(0.,5.,100)
y = np.exp(-x)
plt.plot(x,y,'k',linewidth=2)
plt.savefig("plot.eps",bbox_inches=0)

Preview cannot open plot.eps (it fails to convert it to pdf). On Arch Linux (for which I have matplotlib 1.3.1 on Python 3.3.3), the example script does not produce a corrupt file, and the difference appears to be in a few lines at the end of the file. plot.eps produced on the Mac has the lines

%%PageTrailer
%%Trailer
cleartomark
countdictstack
exch sub { end } repeat
restore
end
%%EOF

whereas the Linux plot.eps has instead

%%PageTrailer
%%Trailer
cleartomark
end
countdictstack
exch sub { end } repeat
restore
%%EOF

If I manually edit plot.eps using nano on the Mac and move the line with the word 'end' to where it is in the Linux file, then plot.eps opens in Preview and the problem disappears.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions