From: BXC (Bendix Carstensen) <bxc_at_steno.dk>

Date: Sun, 18 May 2008 17:34:46 +0200

This is an experiment with two plots.

\end{figure}

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. Received on Sun 18 May 2008 - 21:59:12 GMT

Date: Sun, 18 May 2008 17:34:46 +0200

Thanks a lot yuor advice works, here is an actually working example of
an .rnw file, where the graphs are stuffed in a subfolder:

\documentclass{article} \begin{document} \SweaveOpts{include=FALSE}

This is an experiment with two plots.

Here is the first:

<<CHUNK1, fig=TRUE, echo=TRUE, eps=FALSE, width=3, height=7,
prefix.string=./graph/xx>>=

x<-seq(-2*pi, 2*pi, .1)

plot(x, sin(x), type="l", lwd=4)

@

And here is the second:

<<TJUNK2, fig=TRUE, echo=TRUE, eps=FALSE, width=7, height=7,
prefix.string=./graph/xx>>=

x<-seq(-2*pi, 2*pi, .1)

plot(x, cos(x), type="l", lwd=4)

@

The result should be two graphs side by side:
\begin{figure}[h]

\centering \includegraphics[width=0.27\textwidth]{./graph/xx-CHUNK1} \hfill \includegraphics[width=0.63\textwidth]{./graph/xx-TJUNK2} \caption{\it Here is the caption.} \label{fig:Tschunks1und2}

\end{figure}

\end{document}

> -----Original Message-----

*> From: Charilaos Skiadas [mailto:cskiadas_at_gmail.com]
**> Sent: 18. maj 2008 17:08
**> To: BXC (Bendix Carstensen)
**> Cc: r-help_at_r-project.org
**> Subject: Re: [R] Figure environment and includegraphics
**> options from Sweave
**>
**>
**> On May 18, 2008, at 10:41 AM, BXC (Bendix Carstensen) wrote:
**>
**> > Tha handy thinb about the fig=TRUE option in Sweave is that
**> you do not
**> > have to bother about filenames and starting and stpping the device.
**> >
**> > I want the the resulting LaTeX to look as:
**> >
**> > \begin{Schunk}
**> > \begin{Sinput}
**> >> x <- seq(-2 * pi, 2 * pi, 0.1)
**> >> plot(x, cos(x), type = "l", lwd = 4)
**> > \end{Sinput}
**> > \end{Schunk}
**> >
**>
**> > \begin{figure}
**> > \includegraphics[width=0.6\textwidth]{xx-001}
**> > \end{figure}
**> >
**>
**> > i.e. with options to the \includegraphics and all embedded
**> in a figure
**> > environment.
**> >
**> > 1)
**> > Is there a way to do this without writing the figure environment
**> > manually?
**>
**> The Sweave manual (section 4.1.2 in my version) suggests
**> using something like this before the figure call:
**>
**> \setkeys{Gin}{width=0.6\textwidth}
**>
**> This sets the size globally. Not perfect, but it's what I've
**> been doing.
**> I would myself like the ability to add optional arguments to
**> the produced \includegraphics call, but perhaps there is a
**> good reason why this hasn't been implemented (other than that
**> the developer might not have thought it useful/necessary,
**> which is in itself a perfectly good reason why this feature
**> is not there).
**>
**> > 2)
**> > If not, is there a way to get the generated filename of the
**> plot, or
**> > to explicitly give it in the .rnw file? The point of course
**> being to
**> > avoid to start and stop the graphics driver explicitly?
**>
**> I haven't tried it, but perhaps if you have a named figure
**> code chunk, this name is used for the file name?
**>
**> > Best,
**> > Bendix Carstensen
**> > ______________________________________________
**> >
**> > Bendix Carstensen
**> > Senior Statistician
**> > Steno Diabetes Center
**> > Niels Steensens Vej 2-4
**> > DK-2820 Gentofte
**> > Denmark
**> > +45 44 43 87 38 (direct)
**> > +45 30 75 87 38 (mobile)
**> > bxc@steno.dk http://www.biostat.ku.dk/~bxc
**>
**> Haris Skiadas
**> Department of Mathematics and Computer Science Hanover College
**>
**>
**>
**>
**>
*

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. Received on Sun 18 May 2008 - 21:59:12 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 26 May 2008 - 20:31:29 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*