[R] Changing size of lattice plot?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Oct 29 11:41:31 CET 2007
The 'base height and width of a lattice plot' are the dimensions of the
graphics device in use. You set those when you open the graphics device
(which you are using was unstated, as was your OS), and each device has
device-specific defaults. I'd suggest something like
windows(width=8, height=5)
x11(width=8, height=5)
...
would be more appropriate, but for a screen device you can resize the
window to get the effect you are looking for.
On Mon, 29 Oct 2007, Rory Winston wrote:
> Hi
>
> I am having a bit of difficulty with changing the canvas size on a
> trellis/lattice plot. I am plotting two "cubes" of 3-dimensional random
> numbers, as follows:
>
> library(gsl)
> library(lattice)
> q <- qrng_alloc(type="sobol", 3)
> npoints <- 200
> rs <- qrng_get(q,npoints)
>
> # Plot the normal variates in a 3-dim cube
> p1 <- cloud(rnorm(npoints) ~ rnorm(npoints) + rnorm(npoints), xlab="x",
> ylab="y",
> zlab="z", pch=21, main=paste(npoints,"3-Dimensional ~N(0,1)"))
> p2 <- cloud(rs[,1] ~ rs[,2] + rs[,3], xlab="x", ylab="y",
> zlab="z", pch=21, main=paste(npoints,"3-Dimensional Sobol"))
> print(p1, split=c(1,1,2,1), more=TRUE)
> print(p2, split=c(2,1,2,1))
>
>
> This plots fine, however the canvas size is much too large - there is a
> large amount of whitespace above and below the cloud plots. I have tried
> fiddling with the margins, e.g.
>
> trellis.par.set(layout.heights =
> list(top.padding = -20,
> main.key.padding = 1,
> key.axis.padding = 0,
> axis.xlab.padding = 0,
> xlab.key.padding = 0,
> key.sub.padding = 0,
> bottom.padding = -20))
>
> But this just moves the figure and legend around inside a fixed-size canvas.
> Does anybody know how I can set the base height and width of a lattice plot?
>
> Cheers
> Rory
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list