Hi, With the following Sweave minimal file:
---<--------------------cut here---------------start------------------->--- \documentclass{article} \usepackage{Sweave} \begin{document} <<binom-sim>>= thetas <- seq(0, 1, by=0.001) prior <- rep(1, length(thetas)) / length(thetas) lik <- dbinom(1, 1, thetas) lik.p <- prior * lik post <- lik.p / sum(lik.p) <<binom-sim-fig, fig=TRUE, include=FALSE, height=3, echo=FALSE>>= layout(matrix(1:2, ncol=2)); par(mar=c(5, 4, 2, 1), cex=0.75) matplot(thetas, cbind(prior, lik, post), type="l", lty=c(2, 1, 1), xlab="theta", ylab="probability density") lik <- dbinom(60, 100, thetas) lik.p <- prior * lik post <- lik.p / sum(lik.p) matplot(thetas, cbind(prior, lik, post), type="l", lty=c(2, 1, 1), xlab="theta", ylab="probability density") @ \includegraphics[width=\linewidth]{test-binom-sim-fig} \end{document} ---<--------------------cut here---------------end--------------------->--- If the embedded chunks are evaluated directly in an R session, two different panel data are produced by layout(), as expected. However, when weaving and latexing the file produces, then the two panels show the same data, corresponding to the last data set. This doesn't happen if the data are much simpler, say using matplot() with simple sequences of numbers. Any ideas what is causing this and how to get around it? Cheers, -- Seb ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.