Question

I am preparing a Latex document and a slide show for my Bayesian analysis results. Trace plots generated by "coda" package in R are very large in size. By size, I mean kilobytes (KB), and loading time. When I am scrolling down the pdf files in a slow computer or IPAD, it takes quite a lot of time to load the pages that are involving trace plots. Is there any way to "lighten" those plots, so that the scrolling times decreases substantially? (such as converting to another format without losing much detail).

Note: I am using Rstudio and knitr to produce latex documents.

For example, I generated a plot using following code. If I export it to a single page PDF document, the size of the PDF will be 439 KB (compared to basic plots with sizes 7 KB).

library(coda)
temp <- mcmc(matrix(rnorm(100000),ncol=1))
traceplot(temp) 
Was it helpful?

Solution

I would recommend you dump the images not as pdf, but as png. If you ensure that the png has a high enough resolution, it will be hard to see the difference between the pdf and the png. The png will be much faster than the pdf, speeding up scrolling.

OTHER TIPS

PDF would have the advantage to scale, but the disadvantage is the rendering of bigger vector data.

In order to keep the scalability, what can be done is flattening and simplifying the "plot output" (I am sure that curves are split up into hundreds of minuscule straight lines). There should be tools out there which can do it (if needed get the PDF into Illustrator and do it there).

But even with simplifying, you may eventually get beyond the tolerable limits, and in this case, rasterizing the plot is the way to go. PNG has been suggested as format; TIFF would work as well. However, NEVER EVER do JPEG from plots; the quality would become horrendously bad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top