I am trying to create a graphic output in Sweave but I do not want it to be standard size. I want the whole graphic to be 80mm of height only, just like the viewport below. <<fig=TRUE, echo=TRUE>> pushViewport(viewport(height = unit(80, "mm"))) grid.rect() grid.text("I want this viewport to be the whole output size") popViewport() @ How can I make the graphic smaller (80mm of height) without having the white margins at the top and bottom? A lot of thanks in advance, Mark
On 4/7/2009 10:39 AM, Mark Heckmann wrote:> I am trying to create a graphic output in Sweave but I do not want it to be > standard size. I want the whole graphic to be 80mm of height only, just like > the viewport below. > > <<fig=TRUE, echo=TRUE>>> pushViewport(viewport(height = unit(80, "mm"))) > grid.rect() > grid.text("I want this viewport to be the whole output size") > popViewport() > @ > > How can I make the graphic smaller (80mm of height) without having the white > margins at the top and bottom?You can specify height and width as arguments to the code chunk or set new defaults with something like \SweaveOpts{width=5,height=3} (I think those measurements need to be given in inches; I don't think there's a way to use an expression like unit(80,"mm").) You can also control the size of the plot in the final document with LaTeX code like \usepackage{graphicx} \setkeys{Gin}{width=3in} and then the LaTeX rules for handling units would apply, so 80mm is fine instead of 3in. Duncan Murdoch
Mark Heckmann <mark.heckmann <at> gmx.de> writes:> I am trying to create a graphic output in Sweave but I do not want it to be > standard size. I want the whole graphic to be 80mm of height only, just like > the viewport below. > > <<fig=TRUE, echo=TRUE>>> pushViewport(viewport(height = unit(80, "mm"))) > grid.rect() > grid.text("I want this viewport to be the whole output size") > popViewport() > @ > > How can I make the graphic smaller (80mm of height) without having the white > margins at the top and bottom?<<fig=TRUE, height=3.1>> I would avoid echo=TRUE with figures, this could lead to confusing results. Note that height is in inches, hope I guess this right. I also suggest not to set heights explicitly afterwards, and avoid aspect (in lattice) for the first try. Nevertheless, getting small borders in Sweave has driven me crazy more than once. Dieter