[R] Sweave: side by side dynamic graphs

Felipe Carrillo mazatlanmexico at yahoo.com
Mon Nov 3 16:22:34 CET 2008


Thanks Dieter, I didn't know about 'minipage' but I was actually going to try par'(mfrow=c(1,2))' this morning. Thanks for your help again.



--- On Sun, 11/2/08, Dieter Menne <dieter.menne at menne-biomed.de> wrote:

> > I'm trying to create some side by side dynamic
> graphics on the same page but 
> 
> Thanks for the example; there was a minor typo so that it
> did not run "plot(}",
> and a major problem that could have caused serious problem
> (happens to me quite
> often due to copy and paste)
> 
> <<fig.R,echo=F,fig=T,width=2.5,height=2.5>>=
> 
> You must give the << sections with graphics different
> names, otherwise the wrong
> picture will be used. 
> 
> For side-by-side, you simply plot side by side, or use
> minipages when captions
> are needed for both figures. In the first case, trellis
> graphs are much more
> space-conservative.
> 
> Dieter
> 
> 
> 
> \documentclass[12pt]{article}
> % For a minimal example, please remove all special packages
> \begin{document}
> \begin{figure}[h]
> \centerline{\mbox{\includegraphics[width=3.00in]{bar}}
> \mbox{\includegraphics[width=3.00in]{bar}}}
> \end{figure}
> 
> \begin{figure}[ht]
> \centering
> <<Rdouble,echo=F,fig=T,width=5,height=2.5>>=
> par(mfrow=c(1,2))
> plot(1:10)
> plot(1:10)
> @
> \caption{When you do not need separate captions, this
> is the easiest way.}
> \end{figure}
> 
> \begin{figure}[ht]
> \begin{minipage}[b]{0.5\linewidth}
> \centering
> <<RsingleA,echo=F,fig=T,width=2.5,height=2.5>>=
> plot(1:10)
> @
> \caption{First figure}
> \label{fig:figure1}
> \end{minipage}
> \hspace{0.5cm}
> \begin{minipage}[b]{0.5\linewidth}
> \centering
> <<RsingleB,echo=F,fig=T,width=3,height=3>>=
> plot(1:15)
> @
> \caption{Second figure}
> \label{fig:figure2}
> \end{minipage}
> \end{figure}
> \end{document}
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list