编织物:如何显示彼此相邻的两个大小不同的图? [英] knitr: How to show two plots of different sizes next to each other?
本文介绍了编织物:如何显示彼此相邻的两个大小不同的图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想生成两张不同大小的图像,但并排显示它们.这可能吗?
I wanted to generate two images of different sizes, but show them side-by-side. Is this possible?
这可行,但是它们的大小必须相同:
This works, but then they have to be the same size:
```{r two_plots_same_size_side_by_side, fig.width=5, fig.height=5}
plot(...)
plot(...)
```
这是行不通的,但是由于在Markdown中,由单个换行符分隔的行会出现在同一行上.
This doesn't work, but it could since in Markdown, lines that are separated by a single newline, appear on the same line.
```{r normal_plot, fig.width=5, fig.height=5}
plot(...)
```
```{r tall_plot, fig.width=5, fig.height=9}
plot(...)
```
推荐答案
如果要输出为HTML,另一个选项是使用out.extra=
块选项,并将它们设置为块内的float对象.例如.
Another option, if you're outputting to HTML is to use the out.extra=
chunk option, and set them to be float objects within a block. For example.
```{r fig.width=4, fig.height=6,echo=FALSE,out.extra='style="float:left"'}
plot(cars)
```{r fig.width=8, fig.height=6,echo=FALSE, out.extra='style="float:left"'}
plot(cars)
```
这篇关于编织物:如何显示彼此相邻的两个大小不同的图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文