Michael Friendly
2009-Jan-27 14:06 UTC
[R] Windows, gsview: corrupted bbox of .e?ps graphics
System: [Windows XP Pro, R 2.8.0 and R 2.81.] When I do R graphics on Windows and want .eps output for LaTeX, with *tight bounding boxes* I usually do as follows from Rgui: - Save as Postscript ... myfig.ps - Open myfig.ps in Gsview, select PS to EPS, Save as ... myfig.eps This always worked before, and gave me .eps files that did not include much more white space than I like, didn't require fiddling with par(), nor using \includegraphics[trim=....]{myfig}. But now I've encountered a problem that prevents this workflow from working --- when I now open *any* R-generated-this-way .ps or .eps file, with GSview (v 4.9), the bounding box of the graphic is corrupted-- i.e., the bounding box I see cuts off the top half of the figure. See: http://euclid.psych.yorku.ca/SCS/Private/agree-MS-buggged.eps for the example produced below. This does view OK with gv on linux, however, the usual tool I use on linux to find new, tight bbox won't work on this file: %psfixbb -l agree-MS-bugged.eps psfixbb: Probloem with new %%BoundingBox: -4 -4 616 796 What caused this was an example from vcd, that I wanted in .eps form. What I got from my usual method of Save as Postscript was not at all pleasing--- font sizes in the .ps image were way larger than what appeared on the screen. So, I added a postscript() command to the example in ?agreementplot library(vcd) data("MSPatients") ## best visualized using a resized device, e.g. using: #get(getOption("device"))(width = 12) dev.new() postscript(file="agree-MS.ps", paper="special", horizontal=FALSE, width=6.0, height=3.0) pushViewport(viewport(layout = grid.layout(ncol = 2))) pushViewport(viewport(layout.pos.col = 2)) agreementplot(t(MSPatients[,,1]), main = "Winnipeg Patients", newpage = FALSE) popViewport() pushViewport(viewport(layout.pos.col = 1)) agreementplot(t(MSPatients[,,2]), main = "New Orleans Patients", newpage = FALSE) popViewport(2) dev.off() Ever since, when I use gsview on Win to view *any* .eps file generated via Save as Postscript from the R graphics window, I get similar behavior. This happens in a fresh R session, as well as with R 2.8.1. It doesn't happen with Sweave-generated graphics (but I haven't tried the above example in Sweave). Any ideas on what is wrong and how I can fix this? -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 C NADA