Manage alignment of two side-by-side graphs in knitr

I can’t figure out how to place two side by side as described in the critreus user guide, page 2 ( http://yihui.name/knitr/demo/graphics/ ), I use the following MWE, and the output is lower. I would like them to be aligned as shown in the manual for the two car sections (also on page 2 of the manual). PDF is created 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) ``` 

enter image description here

+10
r knitr r-markdown
source share
1 answer

To center two plots, you can add fig.align='center' to your fragment settings. If he creates one chart over another, add also fig.show='hold' . The result should be two centered graphs. Result

So, you, the last option, should look something like this:

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

All Articles