[Rd] Suboptimal EPS output (PR#8502)
mike.prager@noaa.gov
mike.prager at noaa.gov
Wed Jan 18 17:30:09 CET 2006
Full_Name: Mike Prager
Version: 2.2.1
OS: Windows XP with SP2
Submission from: (NULL) (205.156.36.17)
When several EPS files are made with one invocation of postscript(), only the
first displays correctly in gsview. Examination of the generated eps files with
a diff utility reveals that subsequent eps files lack the encoding vector
definition and report page numbers higher than one. This causes (e.g.) gsview to
fail when trying to display the subsequent files.
My copy of the EPS specification does not prohibit %%Pages DSC comments higher
than one, but since an EPS file is not allowed to have multiple pages, it seems
inconsistent at least for the R-generated file to claim to be page 2 or that it
contains more than one page.
The lack of encoding vector definition causes font loading to fail when it the
file later specifies WinAnsiEncoding (as it does by default).
Therefore, it would be desirable for each generated eps file to include the
encoding vector and to state that it is page 1 of 1 and that the number of pages
is 1.
(This can be worked around by closing the device between plots, thus making sure
each EPS file is the first file.)
The following example generates two files, the second of which is incompatible
with gsview on Windows as described:
######################################################################
# epstest.r
# M. H. Prager
# Demonstrate (1) possible wrapper function for postscript() and
# (2) problems with current EPS output
# January 17, 2006
######################################################################
eps <- function (...)
{
postscript(height = 5, width = 7, onefile = FALSE, horizontal = FALSE,
paper = "special", file = "Rplot%03d.eps", ...)
}
eps()
plot(1:5, rnorm(5))
plot(1:6, rnorm(6))
dev.off()
# END OF EXAMPLE
######################################################################
In addition, although it is NOT a bug, I would like to request that a wrapper
function like eps() above be included with the R distribution. This would save
R-help readers from answering the same questions over and over. It would also
make it easier for newcomers to use R for generating eps files. Consideration by
the R Core Team would be appreciated.
Thanks,
...Mike Prager
More information about the R-devel
mailing list