Skip to content

changing Swaeve output settings for .pdf and .eps - is there a way?

6 messages · Mark Heckmann, cls59, Duncan Murdoch +1 more

#
Is there a way to change the default settings for Sweave figure output?
Sweave produces an .eps and a .pdf file as output (7x7 inch). Changing pdf
defaults changes the pdf() function output size but does not affect the pdf
size produced by Sweave.

pdf.options(height=3)
pdf("myfile.pdf")
	plot(1:10)
dev.off()

--> graphic height is 3 inch

<<>>=
pdf.options(height=3)
@
<<fig=TRUE, echo=TRUE>>=
	plot(1:10)
@

--> graphic height is 7 inch

The pdf() settings do not affect Sweave settings when producing a .pdf
graphic. How can I change the Sweave default settings to e.g. 3 inch?

TIA, Mark


PS. I posted a similar matter a week ago
(https://stat.ethz.ch/pipermail/r-help/2009-April/194352.html), but now I
think the question is much more precise.

-------------------------------

Mark Heckmann
www.markheckmann.de
http://ryouready.wordpress.com
#
markheckmann wrote:
Try setting the width and height options in the figure chunk:

<<fig1,echo=F,plot=T,pdf=T,width=5,height=3>>
    plot(1:10
@

To make a certain set of dimensions the defaults, use \SweaveOpts:

\SweaveOpts{width=5,height=3}

-Charlie



-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
#
markheckmann wrote:
Also, even if you set the width of your plot to 3 inches, the plot will be
expanded to 80% of the textwidth by default.  To disable this (i.e you set
width=3 and your plot is actually 3 inches) use 

\usepackage[nogin]{Sweave}.
  
You will have to copy Sweave.sty to your local directory or to your texmf
directory for this to work.
#
cameron.bracken wrote:
You shouldn't need Sweave.sty in your local directory for this to work.  
You aren't changing it,
just using one of its options.

There are other ways to control the size:  it isn't always 80%.  I 
normally use something like
\setkeys{Gin}{width=0.75\textwidth} to control it.  You can reset this a 
number of times in
the same document.  (Read the LaTeX docs for graphicx to see the other 
keys that can be set.)

Duncan Murdoch
#
Duncan Murdoch-2 wrote:
The reason I suggested using the nogin option is because the default
behavior has always seemed very unintuitive to me.  It seems that setting a
width and/or height parameter should be the only thing that needs to be done
to determine the size of the graphic.  I know this is documented but I think
it is overly confusing to a new user.   I know the first time I set width=3
and the plot still spanned 80% of the page threw me off.
#
cameron.bracken wrote:
I second this.

-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University