Dam*_*ian 12 pdf r rstudio knitr
我想将绘图与编织生成的pdf文档的页面中心对齐.我可以使用水平对齐绘图到中心,fig.align='center'但无法弄清楚如何使绘图垂直对齐到中心.
我一直在使用以下代码:
---
header-includes: \usepackage{graphicx}
output:
pdf_document
geometry:
left=1in,right=1in,top=1in,bottom=1in
---
```{r,fig.align='center',out.extra='angle=90', echo=FALSE}
library(ggplot2)
ggplot(diamonds, aes(y=carat, x=price, colour=clarity))+geom_point()+
facet_wrap(~cut)
```
Run Code Online (Sandbox Code Playgroud)
CL.*_*CL. 12
在LaTeX方面,垂直居中的数字必须是figure有位置的p.如何使用knitr取决于:
figure环境中(请参阅参考资料fig.env).然后只fig.pos = 'p'需要附加选项.如果图中没有标题(通常是坏标题),您可以手动添加figure环境:
\begin{figure}[p]
```{r,fig.align='center',out.extra='angle=90', echo=FALSE}
library(ggplot2)
ggplot(diamonds, aes(y=carat, x=price, colour=clarity))+geom_point()+
facet_wrap(~cut)
```
\end{figure}
Run Code Online (Sandbox Code Playgroud)请注意,这在编译为PDF时有效,但会将PDF限制为输出格式.
| 归档时间: |
|
| 查看次数: |
19133 次 |
| 最近记录: |