Marc Schwartz wrote: > On Sun, 2007-12-09 at 01:04 +0000, Jonas Stein wrote: >> Hi, >> >> what is actually the best method to include R-plots into LaTeX >> documents? >> At the moment i use >> >> postscript("myplot.eps", width = 12.0, height = 9.0, horizontal = >> FALSE, >> onefile = TRUE, paper = "special",encoding = "TeXtext.enc") >> plot(foo,bar) >> dev.off() >> >> But it is a bit unhandy to scale later and its difficult to get nice >> formula in the plots. >> >> And how should i write formulas on the axis or at specific points? >> Has someone had some effort in exporting plots to pstricks or pictex? >> >> kind regards and thank you for reading so far, > > As per the Details section of ?postscript: > > The postscript produced for a single R plot 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". Note that the bounding box is for the device region: if you > find the white space around the plot region excessive, reduce the > margins of the figure region via par(mar=). > > > In your code above, change 'onefile = TRUE' to 'onefile = FALSE'. > > For scaling you can use the LaTeX \includegraphics directive along with > several height and width arguments, such as: > > \includegraphics[width=4in]{myplot.eps} > \includegraphics[height=4in]{myplot.eps} > \includegraphics[scale=0.75]{myplot.eps} > \includegraphics[width=0.4\textwidth]{myplot.eps} > > You might want to review the following document: > > ftp://ftp.tex.ac.uk/tex-archive/info/epslatex.pdf > > For including formulae in R plots, see ?plotmath. You can run > example(plotmath) and there are many posts in the r-help archives on > this. > > Beyond the above, you may want to look into using SWeave, whereby you > can create entire documents, with nicely formatted tables and plots > directly from R code. More information here: > > http://www.ci.tuwien.ac.at/~leisch/Sweave/ > > There are also a couple of articles on R News: > > Friedrich Leisch. Sweave, part I: Mixing R and LATEX. R News, > 2(3):28-31, December 2002. > > Friedrich Leisch. Sweave, part II: Package vignettes. R News, > 3(2):21-24, October 2003. > > HTH, > > Marc Schwartz
In addition to Marc's excellent summary (as usual) please see http://biostat.mc.vanderbilt.edu/SgraphicsHints and especially the link about putting LaTeX typesetting inside graphics (which requires Perl). Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.