【问题标题】:Embed R plot in beamer frame using knitr使用 knitr 在投影仪框架中嵌入 R 图
【发布时间】:2014-04-06 05:03:36
【问题描述】:

我正在尝试调整投影仪对象中绘图的垂直对齐方式。这是一个例子:

\documentclass{beamer}
% To change margins for all slides
\setbeamersize{text margin left=0.5cm,text margin right=0.5cm}

\begin{document}

\title{Title of talk}
\author{John Doe}

\maketitle

\begin{frame}[fragile]
\frametitle{Make a plot}

Code:
<<plot_something, fig.width=3.5, fig.height=3.5, fig.align='center'>>=
plot(1:100, rnorm(100), ylab = "Random value")
@

\end{frame}

\end{document}  

生成的 .pdf 文件中的绘图位置太靠下。如何调整位置以便更有效地使用绘图上方的空白?

【问题讨论】:

    标签: r plot latex knitr


    【解决方案1】:

    我想通了。绘图对象的标准边距很宽,因此重置它们就可以了:

    \documentclass{beamer}
    % To change margins for all slides
    \setbeamersize{text margin left=0.5cm,text margin right=0.5cm}
    
    \begin{document}
    
    \title{Title of talk}
    \author{John Doe}
    
    \maketitle
    
    \begin{frame}[fragile]
    \frametitle{Make a plot}
    
    Code:
    <<plot_something, fig.width=3.5, fig.height=2, fig.align='center'>>=
    par(mai=c(0.4,0.4,0.2,0.2))
    plot(1:100, rnorm(100), ylab = "Random value")
    @
    
    \end{frame}
    
    \end{document}  
    

    【讨论】:

      猜你喜欢
      • 2015-04-21
      • 2016-04-21
      • 2014-05-09
      • 1970-01-01
      • 2019-11-22
      • 2017-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多