TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

x <- rnorm(1000)
y <- rnorm(1000)

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:

share|improve this question
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

For the figures something like,


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.,


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

share|improve this answer
In R all the text comes through as egregiously large. How can I scale the text simultaneously? Is there a scale option? – ashkan Feb 15 '15 at 22:04

I usually put


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)

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

share|improve this answer

Your Answer


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.