问题
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.
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')
@
I can't post an image, but in the compiled pdf the plots appear under each other, not side-by-side.
My code was copied directly from the knitr graphics manual so I don't understand why the plots are not side-by-side.
Changing the out.width
multiplier does change the width of the plots, but at no time do they appear on the same line.
Any suggestions?
LyX Version 2.0.5.1 R version 3.0.1 knitr 1.5
回答1:
There was a global option fig.show
set in the first chunk:
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')
@
来源:https://stackoverflow.com/questions/19398386/cannot-get-lyx-to-produce-two-plots-are-not-on-same-line-when-using-knitr