[R] OT: ps -> eps -> MS Word

Emmanuel Paradis paradis at isem.univ-montp2.fr
Thu Sep 13 12:08:55 CEST 2001


At 20:56 12/09/01 -0700, "Marc R. Feldesman" wrote:
>I've created a bunch of postscript trees (post.rpart), which I subsequently 
>edit in Adobe Acrobat 4.05 (I need additional labelling that isn't easy to 
>add with R).

I believe it is actually easy. You can use text() and a few other functions
to do so. For instance, taking the example from ?post.rpart

 library(rpart)
 data(car.test.frame)
 z.auto <- rpart(Mileage ~ Weight, car.test.frame)
# plot the tree with an extra space below to add labels at the tips
 plot(z.auto, ylim=c(0.2, 1))
# define 4 labels (A to D)
 labels <- LETTERS[1:4]
# get the points where you want to put the labels with the mouse
 locator(4) -> loc1
 text(loc1$x, loc1$y, labels)
# add vertical labels on the main branches
 locator(1) -> loc2
 text(loc2$x, loc2$y, "Group 1", srt=90)
 locator(1) -> loc3
 text(loc3$x, loc3$y, "Group 2", srt=270)
# one more for fun (in the middle of the plot)
 exp <- expression(p == over(1, 1+e^(-(beta*x+alpha))))
 locator(1) -> loc4
 text(loc4$x, loc4$y, exp, srt=45)

Once you have set up all your locations, labels, ..., and possibly add
extra spaces on your plot with xlim, ylim, or adjusting par(mar=), you can
open a PS or a PDF device and execute the plotting commands, e.g.:

 pdf("toto.pdf")
 plot(z.auto, ylim=c(0.2, 1))
 text(loc1$x, loc1$y, labels)
 text(loc2$x, loc2$y, "Group 1", srt=90)
 text(loc3$x, loc3$y, "Group 2", srt=270)
 text(loc4$x, loc4$y, exp, srt=45)
 dev.off()

If you produce a PS file with postscript(), you can then use Ghostscript to
convert it to EPS. But ?postscript says:

     The postscript produced by R is EPS (Encapsulated PostScript)
     compatible, and can be included into other documents, e.g. into
     LaTeX, using `\includegraphics{<filename>}'.  For use in this way
     you will probably want to set `horizontal=FALSE, onefile=FALSE,
     paper="special"'.

Hope this helps.

>  After editing the labels and annotations using Acrobat, I 
>then export the file to Adobe's .eps format so I can insert the picture 
>into a Microsoft Word 2000 document.  The .pdf file distilled from the .ps 
>file is crystal clear, while the .eps file is fuzzy at any resolution in 
>any program (Ghostview 4/Ghostscript 7), Paintshop Pro 7, Word 2000, 
>Powerpoint 2000.  Is there some way to keep the .eps resolution the same as 
>the .pdf/.ps resolution?
>
>(I realize that LaTex is the way to go, but I'm too near completion of this 
>project to change the entire document.  And, the journal is too Neanderthal 
>to accept a manuscript in LaTex format).
>
>I welcome suggestions.
>
>
>
>Dr. Marc R. Feldesman
>email:  feldesmanm at pdx.edu
>email:  feldesman at attglobal.net
>fax:    503-725-3905
>
>"Don't know where I'm going.
>Don't like where I've been.
>There may be no exit.
>But hell, I'm going in."  Jimmy Buffett
>
>Powered by Superchoerus - the 700 MHz Coppermine Box
>
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
.-.-
>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
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
._._
>
>

Emmanuel Paradis
Laboratoire de Paléontologie
Institut des Sciences de l'Évolution
Université Montpellier II
F-34095 Montpellier cédex 05
France
   phone: +33  4 67 14 39 64
     fax: +33  4 67 14 36 10
  mailto:paradis at isem.univ-montp2.fr
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list