# Blackened window instead of plot generated with Sweave [closed]

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>>=
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 Welcome to tex.sx! – David Carlisle Mar 22 at 10:21 Thank you :) Know it works! I knew it was some silly mistake. – alwil Mar 22 at 10:46 OK glad you got it working, we will probably close this as "too localised" rather than leave unopened, hope you don't mind. – David Carlisle Mar 22 at 10:48 Don´t mind at all. – alwil Mar 22 at 11:03

## closed as too localized by David Carlisle, egreg, Torbjørn T., mafp, JakeMar 22 at 10:53

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.