在Rstudio中使用rmarkdown
与knitr
编织Microsoft Word文档时,图形通常看起来很糟糕,因为Microsoft Word不支持常用的矢量图形格式,例如PDF。
幸运的是,R中的devEMF
包生成了微软矢量格式EMF,我几乎可以在我的rmarkdown
应用程序中使用它。问题是我的图像显示得太小了。如何控制图像尺寸?
我已尝试过以下standard things:
---
title: "Plot size trouble demo"
author: "for stackoverflow"
output: word_document
---
Here I include graphics in a word document using the `emf` printing device.
```{r dev = 'emf', fig.ext = 'emf'}
require(devEMF)
plot(1:10, 1:10)
```
The plot is small, so I try to make it bigger with the `fig.height` and fig.width` options:
```{r dev='emf', fig.ext='emf', fig.height=10, fig.width=10}
require(devEMF)
plot(1:10, 1:10)
```
The plot region stayed the same size, and now I have super-small labels and points!
Finally, I try to use the `out.width` and `out.height` options to rescale the figure to a different size, but this produces nothing at all:
```{r dev='emf', fig.ext='emf', fig.height=10, fig.width=10, out.width = '5in', out.height= '5in'}
require(devEMF)
plot(1:10, 1:10)
```
更新:我注意到here rmarkdown支持win.metafile
,但以下内容也没有产生任何内容:
```{r dev = 'win.metafile', out.width = '5in', out.height= '5in'}
plot(1:10, 1:10)
```