Export figures from R to Latex

1,760 views
Skip to first unread message

Biru Zhou

unread,
Feb 9, 2010, 5:26:48 PM2/9/10
to LaTeX Users Group
Hello, everyone

I am having difficulties exporting figures from the statistical
program R to Latex. I think I might have the wrong package. Does
anyone know the step by step way to put the R figures into Latex?
NOTE.

Biru Zhou

unread,
Feb 9, 2010, 5:29:16 PM2/9/10
to LaTeX Users Group
Hello, everyone

I am having difficulties exporting figures from the statistical

program R to Latex. I think I might have the wrong package or
something. Does anyone know the step by step way to put the R
generated figures into Latex? I really mean step by step since I am a
new user for both R and Latex.

NOTE. I am NOT using the {apa} document class, but I am using the
{report} document class.

Thanks a lot!

Cheers,

Biru

Paul Johnson

unread,
Feb 9, 2010, 10:53:28 PM2/9/10
to latexus...@googlegroups.com
Save your files as eps or pdf and then use include graphics to
incorporate into your LaTeX document.

I've written down details in this essay:

http://pj.freefaculty.org/stat/ps706/Downloads/StuffWorthKnowing.pdf

Look in the chapter on Plotting for a section on "how to save graphics in R".

and there is also an R script that demonstrates several ways of saving
graphs here:

http://pj.freefaculty.org/stat/ps706/AboutSavingGraphs.R.

--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

tod.mo...@gmail.com

unread,
Feb 10, 2010, 2:29:56 AM2/10/10
to LaTeX Users Group
Paul's answer is the right way for a beginner, but if you're willing
to read some documentation tikzdevice (http://r-forge.r-project.org/
projects/tikzdevice/) produces really pretty output. See
http://www.texample.net/tikz/examples/tikzdevice-demo/ for some
example code.

On Feb 9, 8:53 pm, Paul Johnson <pauljoh...@gmail.com> wrote:
> Save your files as eps or pdf and then use include graphics to
> incorporate into your LaTeX document.
>
> I've written down details in this essay:
>
> http://pj.freefaculty.org/stat/ps706/Downloads/StuffWorthKnowing.pdf
>
> Look in the chapter on Plotting for a section on "how to save graphics in R".
>
> and there is also an R script that demonstrates several ways of saving
> graphs here:
>
> http://pj.freefaculty.org/stat/ps706/AboutSavingGraphs.R.
>

Marianne Promberger

unread,
Feb 10, 2010, 6:24:12 AM2/10/10
to latexus...@googlegroups.com
Hi,

Biru Zhou <biru...@gmail.com> 09-Feb-10 22:26:

In R:

?postscript
?png
?jpg

eg

postscript(file="myplot.eps",horizontal=FALSE,onefile=FALSE,paper="special",width=5,height=5)
plot(1:10)
dev.off()

Then, include the graphics file like you would into any other LaTeX
document with

\includegraphics{myplot}

If you need more help, please provide more information.

Marianne

--
Marianne Promberger
http://promberger.info
http://participate-in-research.org.uk
GnuPG/PGP public key ID 80AD9916

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

Biru Zhou

unread,
Feb 10, 2010, 10:14:22 AM2/10/10
to latexus...@googlegroups.com
Thanks a lot, guys!!

The comments are very very helpful and they worked!!

Cheers,

Biru

> --
> You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
> To post to this group, send email to latexus...@googlegroups.com.
> To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.
>
>

--
Biru loves La vie en rose

Andrey Paramonov

unread,
Feb 13, 2010, 6:14:11 AM2/13/10
to LaTeX Users Group
You might also want to try my R package cmrutils, which includes
Computer Modern fonts suitable for R plots. Computer Modern is the
default TeX font family. Having consistent fonts makes your documents
look really "professional".

Andrey Paramonov

Reply all
Reply to author
Forward
0 new messages