Making flattened pdfs in Sweave

前端 未结 3 1031
北荒
北荒 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:02

    There is no need to switch to Knitr for this, though there are plenty of advantages in doing so.

    One solution is just to arrange for the plot file to be produced and then include it yourself rather than rely on Sweave to do it for you

    <>=
    png("path/to/fig/location/my_fig.png")
    plot(1:10)
    dev.off()
    @
    
    \includegraphics[options_here]{path/to/fig/location/my_fig}
    

    Another option is to consider whether a plot with a "ton of points" is a useful figure - can you see all the points? Is the density of the points of interest? Alternatives include plotting via the hexbin package or generating a 2-d density of the points and plotting that as a lower-density set of points. The ggplot2 package has plenty of this functionality built in, see e.g. stat__bin2d() or stat_binhex() for examples.

提交回复
热议问题