Question

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

Was it helpful?

Solution

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')
@
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top