Skip to content
Prev 76855 / 398502 Next

Creating very small plots (2.5 cm wide) in Sweave

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