# [R] postscript()

Prof Brian D Ripley ripley at stats.ox.ac.uk
Tue Jul 11 18:29:36 CEST 2000

On Tue, 11 Jul 2000, Peter B. Mandeville wrote:

> I am using RedHat 6.1, the R1.1.0 binary download, and an HP Deskjet 692C.
> For some time I have been trying unsuccessfully to integrate R postscript
> graphics in LaTex. I consulted the Bug Tracking System.

How do you get postscript files to an HP Deskjet 692C, which is not a
postscript printer AFAIK?  It looks to me as if that stage has a bug.

> In the preamble of the LaTex file (test.tex) I have placed the line
>
> \usepackage{graphicx,color}
>
> and I use
>
> \begin{figure}[htbp]
> \begin{center}
> \includegraphics[height=4in]{graphic1.ps}
> \caption{boxplot}
> \end{center}
> \end{figure}
>
> to include the graphic in the document. Using the command
>
> xdvi test
>
> I can preview the document and the graph is shown. I use
>
> dvips test.dvi

There are lots of dvips options that can be set in configuration files.
Try -K here, to pull comments from the included file.

> to print the document. This arrangement works perfectly with poscript
> graphics produced by gimp but the printer hangs at the beginning of the
> graphic when I use graphics generated by the postscript command in R.
>
> An example postscript graph is produced in R by
>
> yield <-
> c(96,37,58,69,73,81,93,81,79,101,96,102,60,54,78,56,61,69,76,89,88,84,75,68)
> variety <- factor(c(rep("I",6),rep("II",6),rep("III",6),rep("IV",6)))
> data <- data.frame(variety,yield)
> postscript("graphic1.ps",horizontal=F)
> boxplot(yield~variety,xlab="Variety",ylab="Yield (bushels per acre)")
> dev.off()

The help page suggests horizontal=FALSE, onefile=FALSE, paper="special".
to produce plots for inclusion in LaTeX.  You might find it easier to plot
on screen and use dev.copy2eps().

> It should be noted that I have tried many postscript graphics files
> generated in R with the same results. I have also checked the help page and
> section 12.6.1 PostScript Diagrams for typeset documents (page 77) in An
> Introduction to R and Lipkin's LaTex for Linux.

Um, but you did not do what the help page suggested.

> The Usage portion of the help page appears to be in error as it has an
> unmatched comma in the first line?

An un-escaped %' in fact. Thanks, now fixed.

>
> I have also tried using the line
>
> postscript("graphic1.ps",horizontal=F,onefile=F)
>
> with the same results.
>
> However, I can read the graphic with gimp and if I save the file as an
> encapsulated postscript file from gimp then the above procedure works. The
> R document is 4,837 bytes in length and the gimp document is 5,289,399
> bytes in length.

> What am I doing wrong?

Perhaps nothing. Your example works on RH6.2 with an actual postscript
printer and the latest teTeX.  My guess is that whatever you are using for
converting the file to PCL to print on your printer has a problem.
This is not implausible, as we have found ghostscript (prior to 6.01,
especially prior to 5.50) unreliable when driving an HP Deskjet 895Cxi.

You may be able to help the process by including a file marked as EPSF
(as suggested on the help page) and by removing comments.

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

`