title: How can I include complicated R plots in a LaTeX document?
body: <p>I'm having the problem with the following code snippet:</p>
  
  <pre><code>\documentclass{article}
  \usepackage{graphicx}
  \begin{document}
  \includegraphics{myscatterplot.pdf}
  \end{document}
  </code></pre>
  
  <p>Where "myscatterplot.pdf" is generated by the following code in R:</p>
  
  <pre><code>library(scatterplot3d)
  pdf("myscatterplot.pdf")
  scatterplot3d(rnorm(100), rnorm(100), 1:100, highlight.3d = TRUE)
  dev.off()
  </code></pre>
  
  <p>The problem is that the resulting LaTeX document when compiling with texworks (pdfLatex+makeindex+bibtex) has the graph axes, but none of the points in the plot or axis labels(In this case, it is just the 3d axes themselves). There are no error or warning messages output by R or LaTeX.
  I am using:</p>
  
  <ul>
  <li>R 2.12.1 on Windows 7, </li>
  <li>MiKTeX 2.8,</li>
  <li>TeXworks</li>
  <li>Adobe Reader 9 (not sure if this is
  relevant...)</li>
  </ul>
  
  <p>I have been able to use the \includegraphics command to include a png version of the figure, and opening "myscatterplot.pdf" with adobe shows the figure I want in my document.</p>
  
  <p>I have tried to use the tikz package as a workaround, but it seems there is so much information generated by scatterplot3d that the resulting figure cannot be included in the latex document due to memory size (error  (my actual plot will have 10000 + points!).  </p>
  
  <p>I have a suspicion that the problem is due to the fonts in the ".pdf" file, but I have tried to change the pdf fonts using </p>
  
  <pre><code>pdf("changefont.pdf")
  par(family = "Helvetica")
  scatterplot3d(rnorm(100), rnorm(100), 1:100, highlight.3d = TRUE)
  dev.off()
  </code></pre>
  
  <p>with precisely the same result when using \includegraphics(changefont.pdf).</p>
  
  <p>The other possible problem I am considering is that maybe the scatterplot3d output is actually multiple images, and \includegraphics is only taking the first of the figures (the axes) from the pdf file.  In this case, I'm still not sure how to work around it.</p>
  
  <p>I would really appreciate a workaround, as I would eventually like to do all of this with Sweave and this is making me bitter toward the otherwise beautiful output of the package!</p>
  
  <p>Thank you in advance for your responses.</p>
  
  <p>Edit 1:</p>
  
  <p>So, the first recommendation was to use the EPS format instead of pdf.  This yielded some results, but not what I wanted.  I ran the following: </p>
  
  <pre><code>\documentclass{article}
  \usepackage{graphicx,epstopdf}
  \begin{document}
  \begin{figure}
  \includegraphics[angle = 270, width= 6in, keepaspectratio=true]{change.eps}
  \end{figure}
  \end{document}
  </code></pre>
  
  <p>I generated "change.eps" using </p>
  
  <pre><code>postscript("change.eps")
  scatterplot3d(rnorm(100), rnorm(100), 1:100, highlight.3d = TRUE)
  dev.off()
  </code></pre>
  
  <p>This <em>did</em> yield an improvement (despite the fact that it, strangely enough, rotated the plot 90 degrees clockwise in the latex output!), and I now have the axes and the points from the scatterplot in my latex output!  However, the axis labels are still not on the figure, even though I have opened "change.eps" using ghostview, and the axes are in the plot!  It seems the way scatterplot3d outputs figures doesn't agree with the way \includegraphics searches for figures...   </p>
  
  <p>So, I'm still looking for a solution to this that will include axes labels.</p>