Poor resolution in knitr using Rmd

后端 未结 3 1148
你的背包
你的背包 2020-12-29 02:30

I have a .Rmd file and I am trying to create a .docx file via the function pandoc.

I want to have a figure with final resolution of 504x504 pixels (i.e., 7x7inch wi

3条回答
  •  一整个雨季
    2020-12-29 03:21

    It's most likely that since this question was asked, the software has improved. I came to this question looking for how to increase the resolution of plots. I found OP's original approach worked out-of-the-box for me.

    So, setting dpi=300 (because dpi=150 did not produce a sufficiently obvious difference) in the chunk's parameters, produced a much higher quality image without modifying the physical size of the images within Word.

    ```{r, echo=FALSE, dpi=300, fig.width=7, fig.height=7}
    plot(0,0,type="n",xlim=c(0,500), ylim=c(-12,0), las=1)
    color  <-  rainbow(500)
    text(380,-1,"Test",pos=4)
    lseq   <-  seq(-6,-2,length.out=500)
    for(j in seq_along(lseq)) {
        lines(c(400,450), rep(lseq[j], 2), col=color[j])
    }
    polygon(c(400,450,450,400), c(-6,-6,-2,-2), lwd=1.2)
    ```
    

    However, setting out.width and out.height removes the production of the image entirely, with the warning "fig.align, out.width, out.height, out.extra are not supported for Word output".

提交回复
热议问题