r - Control alignment of two side-by-side plots in knitr -


i cannot figure out how arrange 2 side-by-side plots explained in knitr graphics manual page 2 (http://yihui.name/knitr/demo/graphics/). use following mwe , output below. them aligned shown in manual 2 cars plots (also on page 2 of manual). pdf generated in rstudio (knit 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

to center 2 plots can add fig.align='center'to chunk options. if produces 1 plot above other add fig.show='hold'. result should 2 centered graphs. result

so final chunk option should like:

{r,echo=false, out.width='.49\\linewidth', fig.width=3, fig.height=3,fig.show='hold',fig.align='center'} 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -