[R] Creating very small plots (2.5 cm wide) in Sweave

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Thu Sep 8 08:15:48 CEST 2005


Dear Francisco,

thanks for your solution.  It turns out that it's best for me to use

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

directly before I call the plot - that seems to work just fine.

Andrwe

On Thu, Sep 08, 2005 at 05:44:59AM +0000, Francisco J. Zagmutt wrote:
> Others may propose more elegant solutions but, in windows one quick an 
> dirty option would be to change the argument 'pin' and 'fin' within par to 
> get an image of exactly 1 inch (2.54 cm) i.e.
> 
> y <- c(40, 46, 39, 44, 23, 36, 70, 39, 30, 73, 53, 74)
> x <- c(6, 4, 3, 6, 1, 5, 6, 2, 1, 8, 4, 6)
> par(pin=c(1,1), fin=c(1,1))
> plot(x, y, xlab="", ylab="")
> abline(h=mean(y), col="red")
> 
> #Save the plot in bmp format
> savePlot("myplot", "bmp")
> 
> and then manually crop the picture using your favorite picture package or 
> even within a word processor.
> 
> I hope this helps
> 
> Francisco
> 
> 
> >From: Andrew Robinson <A.Robinson at ms.unimelb.edu.au>
> >To: R-Help Discussion <r-help at stat.math.ethz.ch>
> >Subject: [R] Creating very small plots (2.5 cm wide) in Sweave
> >Date: Thu, 8 Sep 2005 13:40:17 +1000
> >
> >Hi everyone,
> >
> >I was wondering if anyone has any code they could share for creating
> >thumbnail plots in Sweave.  For example, I'd like a plot like the
> >following:
> >
> >y <- c(40, 46, 39, 44, 23, 36, 70, 39, 30, 73, 53, 74)
> >x <- c(6, 4, 3, 6, 1, 5, 6, 2, 1, 8, 4, 6)
> >opar <- par(mar=c(3,3,0,0))
> >plot(x, y, xlab="", ylab="")
> >abline(h=mean(y), col="red")
> >par(opar)
> >
> >to come out about 2.5 cm wide.
> >
> >Thanks for any assistance,
> >
> >Andrew
> >--
> >Andrew Robinson
> >Senior Lecturer in Statistics                       Tel: +61-3-8344-9763
> >Department of Mathematics and Statistics            Fax: +61-3-8344-4599
> >University of Melbourne, VIC 3010 Australia
> >Email: a.robinson at ms.unimelb.edu.au    Website: 
> >http://www.ms.unimelb.edu.au
> >
> >______________________________________________
> >R-help at stat.math.ethz.ch mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide! 
> >http://www.R-project.org/posting-guide.html
> 

-- 
Andrew Robinson
Senior Lecturer in Statistics                       Tel: +61-3-8344-9763
Department of Mathematics and Statistics            Fax: +61-3-8344-4599
University of Melbourne, VIC 3010 Australia
Email: a.robinson at ms.unimelb.edu.au    Website: http://www.ms.unimelb.edu.au




More information about the R-help mailing list