two column beamer/sweave slide with grid graphic

前端 未结 1 708
Happy的楠姐
Happy的楠姐 2021-01-31 21:04

I\'m trying to make a presentation on ggplot2 graphics using beamer + sweave. Some slides should have two columns; the left one for the code, the right one for the resulting gra

相关标签:
1条回答
  • 2021-01-31 21:45
    • As for the first question, the easy way is to set keep.source=TRUE in SweaveOpts. For more fancy control, see fancyvrb and FAQ #9 of Sweave manual.
    • The width of the figure can be set by \setkeys{Gin}{width=1.0\textwidth}

    here is a slight modification:

    ... snip ...
    
    \SweaveOpts{pdf=TRUE, echo=FALSE, fig=FALSE, eps=FALSE, tidy=T, width=4, height=4, keep.source=TRUE}
    
    \title{Reproducible data analysis with \texttt{ggplot2} \& \texttt{R}}
    
    ... snip ...
    
    
    \begin{document}
    \setkeys{Gin}{width=1.1\textwidth}
    
    ... snip...
    
    <<echo=TRUE,fig=FALSE>>=
    library(ggplot2)
    p <- 
      qplot(mpg,
            wt,
            data=mtcars,
            colour=cyl) +  
      theme_grey(base_family=
                 "Helvetica")
    @
    

    enter image description here

    0 讨论(0)
提交回复
热议问题