[R] How to get correct proportions/bounding box for latex figure?
context grey
mobygeek at yahoo.com
Wed Mar 15 05:14:47 CET 2006
--- Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> The R graphics model is that the drawing surface is
> established first,
> then the things you draw are adjusted to fit in it.
> R won't change the
> shape of the display because you are drawing more
> things on it.
Thanks, this comment clarifies things somewhat.
Though I find it
an odd design choice for R, since it seems to entail
then that
the user has figure out the aspect ratio of the
resulting plot,
something that R could easily keep track of as it is
drawing.
Here's example code, producing 3 scatterplots
side-by-side
(here reusing the same plot for simplicity).
What's desired is that the individual scatterplots
have the
natural aspect, e.g. square, with the axis units being
the
same for X, Y. And to do this while producing a
correct
bounding box in the .eps file.
As it stands the example code produces a correct
bounding box,
but the scatterplots are too stretched to be usable.
Inserting
aspect=1/1 in the xyplot() seems to cause the bounding
box
to be incorrect.
------------
library(lattice)
rand1 <- rnorm(50)
rand2 <- rnorm(50)
theplot <- xyplot(rand1 ~ rand2, xlab="x axis",
ylab="y axis")
thefile <- "plotproblem.eps"
trellis.device(postscript, file=thefile, color=F,
horizontal=FALSE)
print(theplot, split=c(1,1,3,1), more=T)
print(theplot, split=c(2,1,3,1), more=T)
print(theplot, split=c(3,1,3,1), more=F)
dev.off()
-----------------------
> I don't think I understand exactly what you want to
> achieve; sample code
> that produces something close would be helpful (even
> if it comes out the
> wrong shape).
More information about the R-help
mailing list