繁体   English   中英

使用编织器在投影仪框架中嵌入R图

[英]Embed R plot in beamer frame using knitr

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

\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文件中的位置太低了。 如何调整位置,以便更有效地利用绘图上方的空白?

我想到了。 绘图对象的标准边距很宽,因此将其重置可以达到以下目的:

\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}  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM