Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How is it possible to resize figures produced via a Sweave script?

I tried scalebox and others, but I can't succeed to obtain a figure with an acceptable size in my beamer with direct Sweave output like:

<<MyGraph,fig=T>>
x <- rnorm(1000)
y <- rnorm(1000)
plot(x,y)
@

Good answers for figures but for text output ? (see below)

I would also like indications to resize for example an output which is too large for the screen.

For example:

<<MyBigData.Frame,echo=off>>
summary(mybigdata.frame)
@
share|improve this question
1  
Please don't tag it with beamer as long it isn't beamer related, i.e. it works with other classes but not with beamer. If this is the case please state that more clearly in the question. Thanks! –  Martin Scharrer Feb 21 '11 at 11:13
add comment

2 Answers

I usually put

\usepackege[nogin]{sweave}

to the preamble to override default Sweave scaling. That way the width and height of the figure could be controlled by the arguments to the code chunk

<<label=test, fig=TRUE, width=5, height=5>>=
x <- rnorm(1000)
y <- rnorm(1000)
plot(x,y)
@

Depends on your settings you maybe need to copy Sweave.sty to your local directory for this to work.

share|improve this answer
add comment

For the figures something like,

«MyGraph,fig=TRUE,height=4,width=8»= 
…
@

should work. (It defaults to inches.)

To set the default size of all figures in the document with respect to the text block, try, e.g.,

\setkeys{Gin}{width=0.9\textwidth}

You can set absolute widths (in inches or cm) that way, too.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.