I\'d like to align a plot to the center of a page of a knitr-generated pdf document. I can horizontally align the plot to the center using fig.align=\'center\'
but
On the LaTeX side, a vertically centered figure must be a figure with position p. How this can be achieved using knitr
depends:
figure
environment (see fig.env). Then only the additional option fig.pos = 'p'
is needed.If the figure has no caption (which is usually bad), you can manually add the figure
environment:
\begin{figure}[p]
```{r,fig.align='center',out.extra='angle=90', echo=FALSE}
library(ggplot2)
ggplot(diamonds, aes(y=carat, x=price, colour=clarity))+geom_point()+
facet_wrap(~cut)
```
\end{figure}
Note that this works when compiling to PDF but restricts you to PDF as output format.