Reputation: 433
I am trying to adjust the vertical alignment of a plot in a beamer object. Here is an example:
\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}
The position of the plot in the resulting .pdf file is too far down. How do I adjust the position so that the whitespace above the plot is used more efficiently?
Upvotes: 1
Views: 695
Reputation: 433
I figured it out. The standard margins of a plot object are wide so resetting them does the trick:
\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}
Upvotes: 2