Making flattened pdfs in Sweave

前端 未结 3 1065
北荒
北荒 2021-01-06 17:45

So I am creating pdfs using Sweave that include some graphs that have a ton of points on them. I can get the pdf well enough, but it seems to have created it with a ton of l

3条回答
  •  庸人自扰
    2021-01-06 18:06

    As has already been mentioned you should probably switch to knitr, which makes swapping between pdfs and other formats much nicer. In particular, you should look at:

    • the transition guide between knitr and sweave
    • global options: that way you can easily swap between pdfs, high-res png and low-res pngs.
    • caching: only generate the figures when needed.

    Here is an example of using the PNG device:

    \documentclass{article}
    \begin{document}
    
    <>=
    n <- 100000
    DF <- data.frame(x=rnorm(n), y=rnorm(n))
    plot(DF)
    @
    
    \end{document}
    

    There is no need to specify fig=TRUE for knitr. If the image quality of the PNG device in the graphics package is not enough, you can easily switch to other PNG devices, e.g. dev='CairoPNG' or 'Cairo_png'. In Sweave you just write more code to do the same thing.

提交回复
热议问题