getting "small" graphs with Sweave using Rnews.sty

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

getting "small" graphs with Sweave using Rnews.sty

Jeff Hamann
I'm sorry for having to post this, but I can't seem to find any
solutions to this, which seems pretty simple, but then again...

I've started playing with the example r news project and wanted to start
adding some graphs, but replacing:

\begin{figure}
\vspace*{.1in}
\framebox[\textwidth]{\hfill \raisebox{-.45in}{\rule{0in}{1in}}
                       A graph goes here \hfill}
\caption{\label{figure:onecolfig}
A normal figure only occupies one column.}
\end{figure}

yields a an empty box, which is good, with the following:

\begin{figure}
\vspace*{.1in}
<<fig=true,echo=false>>=
plot( rnorm( 100 ) )
@
\caption{A normal figure only occupies one column.}
\label{figure:onecolfig}
\end{figure}

which isn't good, or at least yields a "normal sized" graph that starts
in the second column, when I run Sweave( "yourarticle.rnw" ) and the
pdflatex wrapper

Is it possible, to get a "small" graphic this way, or should I write
out a temp graph as a pdf and include the graphic by constructing the
statement using Sweave?

Thanks for any advice,
Jeff.



______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: getting "small" graphs with Sweave using Rnews.sty

Thierry Onkelinx
Dear Jeff,

Have you tried to insert the graph at the indended position? That is
pasting

<<fig=true,echo=false>>=
plot( rnorm( 100 ) )
@

At the location of

A graph goes here

So the code would be

\begin{figure}
\vspace*{.1in}
\framebox[\textwidth]{\hfill \raisebox{-.45in}{\rule{0in}{1in}}
<<fig=true,echo=false>>=
plot( rnorm( 100 ) )
@
\hfill}
\caption{\label{figure:onecolfig}
A normal figure only occupies one column.}
\end{figure}

HTH,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[hidden email]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: [hidden email] [mailto:[hidden email]]
Namens Jeff Hamann
Verzonden: dinsdag 4 november 2008 3:55
Aan: [hidden email]
Onderwerp: [R] getting "small" graphs with Sweave using Rnews.sty

I'm sorry for having to post this, but I can't seem to find any
solutions to this, which seems pretty simple, but then again...

I've started playing with the example r news project and wanted to start

adding some graphs, but replacing:

\begin{figure}
\vspace*{.1in}
\framebox[\textwidth]{\hfill \raisebox{-.45in}{\rule{0in}{1in}}
                       A graph goes here \hfill}
\caption{\label{figure:onecolfig}
A normal figure only occupies one column.}
\end{figure}

yields a an empty box, which is good, with the following:

\begin{figure}
\vspace*{.1in}
<<fig=true,echo=false>>=
plot( rnorm( 100 ) )
@
\caption{A normal figure only occupies one column.}
\label{figure:onecolfig}
\end{figure}

which isn't good, or at least yields a "normal sized" graph that starts
in the second column, when I run Sweave( "yourarticle.rnw" ) and the
pdflatex wrapper

Is it possible, to get a "small" graphic this way, or should I write
out a temp graph as a pdf and include the graphic by constructing the
statement using Sweave?

Thanks for any advice,
Jeff.



Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: getting "small" graphs with Sweave using Rnews.sty

Dieter Menne
In reply to this post by Jeff Hamann
Jeff D. Hamann wrote
I've started playing with the example r news project and wanted to start
adding some graphs, but replacing:

...
Is it possible, to get a "small" graphic this way, or should I write
out a temp graph as a pdf and include the graphic by constructing the
statement using Sweave?
It is difficult to understand what you mean because your example is not complete. Trying to make a self-running example see below: could you explain?

Dieter


\documentclass[a4paper]{report}
\usepackage{Rnews}
\usepackage{Sweave}
\SweaveOpts{strip.white=all, keep.source=TRUE}

\begin{document}
\begin{article}

\title{My Example}
\maketitle

\begin{figure}
\vspace*{.1in}
\framebox[\textwidth]{\hfill \raisebox{-.45in}{\rule{0in}{1in}}
                       A graph goes here \hfill}
\caption{\label{figure:onecolfig}
A normal figure only occupies one column.}
\end{figure}

yields a an empty box, which is good, with the following:

\begin{figure}
\vspace*{.1in}
<<fig=true,echo=false>>=
plot( rnorm( 100 ) )
@
\caption{A normal figure only occupies one column.}
\label{figure:onecolfig}
\end{figure}

\end{article}
\end{document}
Reply | Threaded
Open this post in threaded view
|

Re: getting "small" graphs with Sweave using Rnews.sty

Duncan Murdoch
In reply to this post by Jeff Hamann
Jeff Hamann wrote:

> I'm sorry for having to post this, but I can't seem to find any
> solutions to this, which seems pretty simple, but then again...
>
> I've started playing with the example r news project and wanted to start
> adding some graphs, but replacing:
>
> \begin{figure}
> \vspace*{.1in}
> \framebox[\textwidth]{\hfill \raisebox{-.45in}{\rule{0in}{1in}}
>                        A graph goes here \hfill}
> \caption{\label{figure:onecolfig}
> A normal figure only occupies one column.}
> \end{figure}
>
> yields a an empty box, which is good, with the following:
>
> \begin{figure}
> \vspace*{.1in}
> <<fig=true,echo=false>>=
> plot( rnorm( 100 ) )
> @
> \caption{A normal figure only occupies one column.}
> \label{figure:onecolfig}
> \end{figure}
>
> which isn't good, or at least yields a "normal sized" graph that starts
> in the second column, when I run Sweave( "yourarticle.rnw" ) and the
> pdflatex wrapper
>
> Is it possible, to get a "small" graphic this way, or should I write
> out a temp graph as a pdf and include the graphic by constructing the
> statement using Sweave?
>
>  
There are two ways to control the size of an Sweave graph:  by telling R
the size you want, and by telling LaTeX how big to make it when you
include it.

You tell R the size by using <<fig=true, width=w, height=h>>= (with w
and h being numbers in units of inches).  You tell LaTeX
(assuming you're using the graphicx package) by using
\setkeys{Gin}{width=w} (or maybe you'd want to set the height, but I
usually just set the width and
let LaTeX scale the height accordingly).  The w here is a LaTeX measure
such as \textwidth or 4in or whatever you like.

I find the font choices in R look a little bit too large if I tell R the
actual size I want, so I generally use both: tell R I want the figure
larger than I really want it, and then tell
LaTeX to shrink it to fit.

Duncan Murdoch

> Thanks for any advice,
> Jeff.
>
>
>  
> ------------------------------------------------------------------------
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: getting "small" graphs with Sweave using Rnews.sty

Felipe Carrillo

\setkeys{Gin}{width=8} gets the desired width but shifts the graph to the right. Is there another latex command to place the graph so that the margins on left and right of the page are the same? \centering or \begin{center} doesn't seem to get it right. I have about one inch margin to my right and about 2.5 inches to my left.

Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Tue, 11/4/08, Duncan Murdoch <[hidden email]> wrote:

> From: Duncan Murdoch <[hidden email]>
> Subject: Re: [R] getting "small" graphs with Sweave using Rnews.sty
> To: "Jeff Hamann" <[hidden email]>
> Cc: [hidden email]
> Date: Tuesday, November 4, 2008, 3:01 AM
> Jeff Hamann wrote:
> > I'm sorry for having to post this, but I can't
> seem to find any solutions to this, which seems pretty
> simple, but then again...
> >
> > I've started playing with the example r news
> project and wanted to start adding some graphs, but
> replacing:
> >
> > \begin{figure}
> > \vspace*{.1in}
> > \framebox[\textwidth]{\hfill
> \raisebox{-.45in}{\rule{0in}{1in}}
> >                        A graph goes here \hfill}
> > \caption{\label{figure:onecolfig}
> > A normal figure only occupies one column.}
> > \end{figure}
> >
> > yields a an empty box, which is good, with the
> following:
> >
> > \begin{figure}
> > \vspace*{.1in}
> > <<fig=true,echo=false>>=
> > plot( rnorm( 100 ) )
> > @
> > \caption{A normal figure only occupies one
> column.}
> > \label{figure:onecolfig}
> > \end{figure}
> >
> > which isn't good, or at least yields a
> "normal sized" graph that starts in the second
> column, when I run Sweave( "yourarticle.rnw" ) and
> the pdflatex wrapper
> >
> > Is it possible, to get a "small" graphic
> this way, or should I write
> > out a temp graph as a pdf and include the graphic by
> constructing the
> > statement using Sweave?
> >
> >  
> There are two ways to control the size of an Sweave graph:
> by telling R the size you want, and by telling LaTeX how big
> to make it when you include it.
>
> You tell R the size by using <<fig=true, width=w,
> height=h>>= (with w and h being numbers in units of
> inches).  You tell LaTeX
> (assuming you're using the graphicx package) by using
> \setkeys{Gin}{width=w} (or maybe you'd want to set
> the height, but I usually just set the width and
> let LaTeX scale the height accordingly).  The w here is a
> LaTeX measure such as \textwidth or 4in or whatever you
> like.
>
> I find the font choices in R look a little bit too large if
> I tell R the actual size I want, so I generally use both:
> tell R I want the figure larger than I really want it, and
> then tell
> LaTeX to shrink it to fit.
>
> Duncan Murdoch
> > Thanks for any advice,
> > Jeff.
> >
> >
> >  
> ------------------------------------------------------------------------
> >
> > ______________________________________________
> > [hidden email] 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.
> >
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: getting "small" graphs with Sweave using Rnews.sty

Duncan Murdoch
On 11/4/2008 11:15 AM, Felipe Carrillo wrote:
> \setkeys{Gin}{width=8} gets the desired width but shifts the graph to the right. Is there another latex command to place the graph so that the margins on left and right of the page are the same? \centering or \begin{center} doesn't seem to get it right. I have about one inch margin to my right and about 2.5 inches to my left.

Remember that by default R doesn't put symmetric margins around plots.
Latex will center the whole plot, including white space.  If you want
the actual plotting area centered, play around with par("mar"), e.g.

par(mar=c(4,4,4,4)+0.1)

for fat margins,

par(mar=c(2,2,2,2)+0.1)

for thin ones (which probably don't have enough room for all the labels
you might add).

Duncan Murdoch

> Felipe D. Carrillo  
> Supervisory Fishery Biologist  
> Department of the Interior  
> US Fish & Wildlife Service  
> California, USA
>
>
> --- On Tue, 11/4/08, Duncan Murdoch <[hidden email]> wrote:
>
>> From: Duncan Murdoch <[hidden email]>
>> Subject: Re: [R] getting "small" graphs with Sweave using Rnews.sty
>> To: "Jeff Hamann" <[hidden email]>
>> Cc: [hidden email]
>> Date: Tuesday, November 4, 2008, 3:01 AM
>> Jeff Hamann wrote:
>> > I'm sorry for having to post this, but I can't
>> seem to find any solutions to this, which seems pretty
>> simple, but then again...
>> >
>> > I've started playing with the example r news
>> project and wanted to start adding some graphs, but
>> replacing:
>> >
>> > \begin{figure}
>> > \vspace*{.1in}
>> > \framebox[\textwidth]{\hfill
>> \raisebox{-.45in}{\rule{0in}{1in}}
>> >                        A graph goes here \hfill}
>> > \caption{\label{figure:onecolfig}
>> > A normal figure only occupies one column.}
>> > \end{figure}
>> >
>> > yields a an empty box, which is good, with the
>> following:
>> >
>> > \begin{figure}
>> > \vspace*{.1in}
>> > <<fig=true,echo=false>>=
>> > plot( rnorm( 100 ) )
>> > @
>> > \caption{A normal figure only occupies one
>> column.}
>> > \label{figure:onecolfig}
>> > \end{figure}
>> >
>> > which isn't good, or at least yields a
>> "normal sized" graph that starts in the second
>> column, when I run Sweave( "yourarticle.rnw" ) and
>> the pdflatex wrapper
>> >
>> > Is it possible, to get a "small" graphic
>> this way, or should I write
>> > out a temp graph as a pdf and include the graphic by
>> constructing the
>> > statement using Sweave?
>> >
>> >  
>> There are two ways to control the size of an Sweave graph:
>> by telling R the size you want, and by telling LaTeX how big
>> to make it when you include it.
>>
>> You tell R the size by using <<fig=true, width=w,
>> height=h>>= (with w and h being numbers in units of
>> inches).  You tell LaTeX
>> (assuming you're using the graphicx package) by using
>> \setkeys{Gin}{width=w} (or maybe you'd want to set
>> the height, but I usually just set the width and
>> let LaTeX scale the height accordingly).  The w here is a
>> LaTeX measure such as \textwidth or 4in or whatever you
>> like.
>>
>> I find the font choices in R look a little bit too large if
>> I tell R the actual size I want, so I generally use both:
>> tell R I want the figure larger than I really want it, and
>> then tell
>> LaTeX to shrink it to fit.
>>
>> Duncan Murdoch
>> > Thanks for any advice,
>> > Jeff.
>> >
>> >
>> >  
>> ------------------------------------------------------------------------
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>> >
>>
>> ______________________________________________
>> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.