控制针织机中两个并排图的对齐 [英] Control alignment of two side-by-side plots in knitr

查看:73
本文介绍了控制针织机中两个并排图的对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚如Knitr图形手册第2页中所述如何排列两个并排图(

I cannot figure out how to arrange two side-by-side plots as explained in the knitr graphics manual page 2 (http://yihui.name/knitr/demo/graphics/). I use the following MWE and the output is below. I would like them to be aligned as shown in the manual for the two cars plots (also on page 2 of the manual). The pdf is generated in RStudio (Knit to PDF).

---
title: "Untitled"
output: pdf_document
---

## R Markdown

```{r,echo=FALSE,out.width='.49\\linewidth', fig.width=3, fig.height=3}

barplot(1:4)
barplot(4:7)

```

推荐答案

要使两个图居中,可以在块选项中添加fig.align='center'.如果它在另一个图上产生一个图,则还要添加fig.show='hold'.结果应该是两个居中的图.

To center two plots you can add fig.align='center'to your chunk options. If it produces one plot above the other add also fig.show='hold'. The result should be two centered graphs.

因此,最后一个块选项应类似于:

So your final chunk option should look something like:

{r,echo=FALSE, out.width='.49\\linewidth', fig.width=3, fig.height=3,fig.show='hold',fig.align='center'}

这篇关于控制针织机中两个并排图的对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆