Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In R, I use par to prepare four boxplots (using boxplot) as a single image, which I save with the png() command. This image is included in a LaTeX document with \includegraphics. I have experimented with exporting different image sizes, and changing the scaling in LaTeX, but the image quality is still poor. I don't really have time to learn Sweave or knitr right now. What settings should I use to optimize the image quality?

share|improve this question

closed as off topic by bloodworks, mafp, zeroth, lockstep, Claudio Fiandrino Feb 14 '13 at 9:23

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Your question aims at how to change the output resolution of R's png() command, so you are asking in the wrong place. Btw, can R output vector graphics like eps or pdf? Then you should use those. –  mafp Feb 14 '13 at 9:14
    
My question was actually related to visualizing that output in LaTeX and my concern that doing so was reducing the quality of the image. –  SabreWolfy Feb 14 '13 at 9:32
1  
Consider that LaTeX will input images as is. This indicates that whatever images are shown with poor quality in the final PDF are due to regular poor image quality. –  zeroth Feb 14 '13 at 9:35
    
My understanding was that using the scale function of \includegraphics may result in lower quality images? Any scaling should be done outside of LaTeX. Hence my question about how to optimize the quality of an R image in LaTeX. I would have preferred that the question be moved to another site, rather than down-voted. –  SabreWolfy Feb 14 '13 at 9:39

1 Answer 1

up vote 4 down vote accepted

Saving the image from R as a PDF rather than a PNG file solved this:

In R:

pdf('theFile.pdf')
# par...
# plot...
dev.off()

In LaTeX:

\includegraphics[scale=0.8]{theFile.pdf}

I did not specify image dimensions in R. The image quality in the final PDF was excellent, even though I scaled it to 80%.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.