[R] How to get correct proportions/bounding box for latex figure?

context grey mobygeek at yahoo.com
Thu Mar 16 00:09:07 CET 2006


That's approximately right, but the individual
scatterplots
are slightly stretched horizontally.   

Is there not any way to have the plots have true 1:1
aspect ratio
(given that the range of the data is the same on both
axes)
and still get a bounding box?.   And, without getting
out
a ruler and manually calculating width/height values?

(I'm guessing you arrived at width=12,height=4 just
by "eyeballing" it.?)

--- Martin Sandiford <ms at mcdev.com.au> wrote:

> Does this do what you want?
> 
> 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, width=12, height=4,
> paper="special")
> 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()
> 
> (Paper size and type specified in trellis.device
> call).
> 
> 
> Martin
> 
> On 15/03/2006, at 2:44 PM, context grey wrote:
> 
> >
> >
> > --- 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).
> >
> > ______________________________________________
> > 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
> >
> 
>




More information about the R-help mailing list