Skip to content

R graphs in LaTeX documents?

4 messages · Michael_Nielsen/Syd/Synergy.SYNERGY@synergy.com.au, Brian Ripley, JRG +1 more

I'll admit to being somewhat of a graphics meathead, but recently needed to
put lots of R graphics into a report that I was typesetting with LaTeX
(well, pdflatex on Linux).  I couldn't coerce pdflatex to use the eps
graphics (it seems to be there has to be a way, but I was in too much of a
hurry to try to find it), so I asked R to generate the graphics directly
into PDF, and then included them into my LaTeX with an \includegraphics.
To me, the result looked pretty good -- much better, in fact, than it did
with either jpg or png output, although the poor result with jpg and png
could well be because of my naive choices for the various settings of
things required along the way.

Anyway, I am continually impressed with R's ability to produce good results
in spite of my somewhat inelegant (ok, ham-fisted) approach.

Regards,

Mike


                                                                                                                           
                    Michael Grant                                                                                          
                    <mwgrant2001 at yahoo.c        To:     Robert Lundqvist <Robert.Lundqvist at ies.luth.se>,                   
                    om>                         "'r-help at lists.R-project.org'" <r-help at stat.math.ethz.ch>                  
                    Sent by:                    cc:                                                                        
                    owner-r-help at stat.ma        Subject:     Re: [R] R graphs in LaTeX documents?                          
                    th.ethz.ch                                                                                             
                                                                                                                           
                                                                                                                           
                    08/02/2002 12:25 AM                                                                                    
                                                                                                                           
                                                                                                                           





--- Robert Lundqvist <Robert.Lundqvist at ies.luth.se>
wrote:
Hi Robert,

Perhaps your difficulties lie on the LaTeX side of the
equation. I've used R versions 1.23, 1.31 and now
1.41; gone thru 'mass production' of numerous
postscript graphics using both the menu and coding;
and pulled those graphics into LaTeX (and
Word)directly without a hitch--EXCEPT IN THE
BEGINNING. And those problems were
first-time-using-LaTeX-related.

Assuming I had saved the R graphic as 'ipu238.eps' the
following (edited) has worked for me:


\documentclass[10pt,letterpaper]{report}
...
\usepackage{graphicx}
...

\begin{document}

...as can be seen in Figure \ref{fig:ipu238}. The
confidence bands are wide and ...

\begin{figure}
           \begin{center}
                     \includegraphics[scale=0.9]{ipu238}
           \end{center}
  \caption{Intervals for plutonium 238 versus europium
154 using all samples.}
           \label{fig:ipu238}
\end{figure}

...

\end{document}


FYI, I use TeXnicCenter/MikTeX for the LaTeX. They
work very well together.(Note: LyX on windows is
cygwin based and requires an Xserver, e.g. XFree86.
Might as run Linux to begin with! Hmmm, not a bad
idea, but RWin is getting pretty sweet.)

Regards,
Mike

__________________________________________________



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Fri, 8 Feb 2002 Michael_Nielsen/Syd/Synergy.SYNERGY at synergy.com.au wrote:

            
The only good way is to convert .eps to pdf (or, much worse, to png).
The best way to do that is Adobe Distiller, the second-best way epsftopdf,
a Perl script / Windows program calling ghostscript, preferably 6.0 or
later.  It is practically identical to what bitmap() does in R.
That's typical for the sort of graphs one produces in R.
I wrote the pdf() driver because it seemed a cleaner solution, and it was
an intellectual challenge.  From this thread it seems it has much more use
than I realized, which is nice to know.
JRG
#
On 7 Feb 02, at 22:20, Prof Brian Ripley wrote:

            
<<<SNIP>>>
I, for one, am extremely grateful for pdf(). Most of the graphics I 
produce with R end up in pdf and the pdf() driver has performed 
flawlessly.  Thank you. 

---JRG












John R. Gleason

Syracuse University
430 Huntington Hall                      Voice:   315-443-3107
Syracuse, NY 13244-2340  USA             FAX:     315-443-4085

PGP public key at keyservers
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
1 day later
#
pdf() has been a *huge* benefit to me, both on its own, and for pdflatex 
graphics inclusion.  Thanks.  An awful lot.

Cheers

Jason