Hello, I am having some problems with the PS backend. I used the following script to create a PostScript file
#!/usr/bin/env python import matplotlib matplotlib.use('PS') import matplotlib.pyplot as plt import numpy x1 = numpy.arange(0,5) y1 = x1 plt.plot(x1, y1) plt.savefig('image.ps') plt.show() When I tried to open the PostScript file in GSview, there is the following warning, and the file does not render properly. I have attached the PostScript file and a screenshot of the incorrect rendering. DSC Error At line 233: %%Page: 1 1 This %%Page: line occurred in the trailer, which is not legal. EPS files should be encapsulated in %%BeginDocument / %%EndDocument. If is possible that an EPS file was incorrectly encapsulated, and that we have been confused by the %%Trailer in an EPS file. The error can be eliminated by removing the line with %%EOF at line 230, and adding %%Trailer after line 1024, but I don't know anything about PostScript or if those changes would have any other effects. I only found this solution after comparing with the output from the Cairo backend. The same change to PostScript output can be achieved with the following diff (from svn diff), but again, I don't know if it is appropriate. Index: lib/matplotlib/backends/backend_ps.py =================================================================== --- lib/matplotlib/backends/backend_ps.py (revision 6760) +++ lib/matplotlib/backends/backend_ps.py (working copy) @@ -1006,6 +1006,7 @@ #print >>fh, "grestore" print >>fh, "end" print >>fh, "showpage" + print >>fh, "%%Trailer" if not isEPSF: print >>fh, "%%EOF" fh.close() Index: ttconv/pprdrv_tt.cpp =================================================================== --- ttconv/pprdrv_tt.cpp (revision 6760) +++ ttconv/pprdrv_tt.cpp (working copy) @@ -1070,7 +1070,6 @@ } /* end of if Type 42 not understood. */ stream.putline("FontName currentdict end definefont pop"); - stream.putline("%%EOF"); } /* end of ttfont_trailer() */ /*------------------------------------------------------------------ Paul Novak
<<inline: screenshot.png>>
ps_backend.ps
Description: PostScript document
------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users