# How can I have labels on the plots in latex, drawn in R

I used R to get different plots. I saved them as pdf. I went to my tex. file and I used \includegraphics command. The plot came but it does not have labels on, that is, x-labels, y-labels and title-labels. Please advice.

• – Konstantinos Jun 6 '14 at 17:59
• Are the labels visible in the .pdf which was saved from R? Try different pdf-viewers on the .pdf created by latex and try zooming in and out in case it is "only" a problem of visualisation of the pdf-viewer – samcarter_is_at_topanswers.xyz Jun 6 '14 at 18:09

Whithout a minimal working example (see I've just been asked to write a minimal example, what is that?) is hard to guess the problem, but a way to overcome this problem and simplify your work is use Sweave (or knitr). Briefly:

1) First, you can make a file.Rnw like this:

\documentclass{article}
Some \LaTeX{} text.
\begin{document}
\SweaveOpts{concordance=TRUE}
<<echo=F,fig=T>>=
data(CO2)
attach(CO2)
plot(uptake~conc, xlab="x label", ylab="y label", main="The main label")
@
\end{document}


2) Then, compile it with R to obtain a file.tex:

R CMD Sweave file.Rnw


3) Finally, Compile your file.tex as usual to obtain file.pdf.

For simple files as the above MWE, or a working preview, where just one pdflatex compilation is enough, you can omit the step 3 and use the--pdf option in 2:

R CMD Sweave --pdf file.Rnw