使用knitr时,无法使LyX生成不在同一行的两个图 [英] Cannot get LyX to produce two plots are not on same line when using knitr

查看:96
本文介绍了使用knitr时,无法使LyX生成不在同一行的两个图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

针织衫新手在这里.喜欢这个程序包,一切都进行得很好,除了一旦在LyX中编译后两个图不会并排出现. 不确定发生了什么,因为我正在逐字复制kn​​itr图形手册(knitr-graphics.lyx)中的示例.

Knitr newbie here. Love the package, and everything is going well except that two plots don't appear side-by-side once compiled in LyX. Not sure what is going on, as I'm copying the example from the knitr graphics manual (knitr-graphics.lyx) verbatim.

我的LyX代码(在图形浮动中):

My LyX code (within a Figure Float):

<<two-high, fig.width=3, fig.height=2.5, out.width='0.49\\linewidth'>>=
plot(cars)
boxplot(cars$dist,xlab='dist')
@

我无法发布图像,但是在已编译的pdf中,地块显示在彼此下方,而不是并排显示.

I can't post an image, but in the compiled pdf the plots appear under each other, not side-by-side.

我的代码是直接从 knitr图形手册"复制而来的,所以我不明白为什么地块不是并排的.

My code was copied directly from the knitr graphics manual so I don't understand why the plots are not side-by-side.

更改out.width乘数的确会更改图的宽度,但决不会出现在同一行上.

Changing the out.width multiplier does change the width of the plots, but at no time do they appear on the same line.

有什么建议吗?

LyX版本2.0.5.1 R版本3.0.1 针织衫1.5

LyX Version 2.0.5.1 R version 3.0.1 knitr 1.5

推荐答案

是第一个块中设置的全局选项fig.show:

opts_chunk$set(fig.show='hold')

这个选项在这里很关键.您可能会在此处看到简单示例.另外,您也可以将其用作本地选项:

And that option is critical here. You may see a simpler example here. Alternatively, you can use it as a local option:

<<two-high, fig.width=3, fig.height=2.5, fig.show='hold', out.width='0.49\\linewidth'>>=
plot(cars)
boxplot(cars$dist,xlab='dist')
@

这篇关于使用knitr时,无法使LyX生成不在同一行的两个图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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