I'm trying to generate two plots side by side using Sweave and the subcaption package.
The thing is, that in the created pdf I get only blackened windows instead of plots (in the separate pdf files the plots generate just fine).
Here“s what I have in my code:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage [section]{placeins}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\SweaveOpts{concordance=TRUE}
\section{One}
\subsection{Density plots}
\begin{figure}[h!]
\centering
\begin{subfigure}{.5\textwidth}
\centering
<<label=fig1,echo=FALSE, fig=TRUE>>=
load("data.RData")
plot(density(data$var1, na.rm=TRUE, to=100), main="", xlab="Var1")
@
\caption{Var1}
\label{fig:fig1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
<<label=fig2, echo=FALSE, fig=TRUE>>=
plot(density(data$var2), main="", xlab="Var2")
@
\caption{Var2}
\label{fig:fig1}
\end{subfigure}
\caption{Var1 and Var2}
\label{fig:var12}
\end{figure}
\end{document}
Do you know what maybe causing this problem? Any bug in my code? Sorry, if my question is too trivial, but I was trying to figure it out on my own for quite a while now and just can't find a right answer.
\usepackage[demo]{graphicx}replaces the images by black squares so that you can post questions without needing the image... just remove[demo]– David Carlisle Mar 22 at 10:20