[R] contourplot, xyplot, aspect ratio, mfrow

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Sun May 2 15:50:24 CEST 2004


Confirmed after checking:

aspect = diff(range(y))/diff(range(x)) in coutourplot looks like being the equivalent of asp = 1  (regarding practical result) in
contour().

Essential for maps!

Thanks a lot for the information and other most valuable hints.

Patrick





----- Original Message ----- 
From: "Deepayan Sarkar" <deepayan at stat.wisc.edu>
To: <r-help at stat.math.ethz.ch>; "Patrick Giraudoux" <patrick.giraudoux at univ-fcomte.fr>
Sent: Sunday, May 02, 2004 3:24 PM
Subject: Re: [R] contourplot, xyplot, aspect ratio, mfrow


> On Sunday 02 May 2004 03:30, Patrick Giraudoux wrote:
> > Hi,
> >
> > I am gradually moving from the classical R plot functions to the
> > library Lattice
> >
> > I have some questions about contourplot () and its arguments:
> >
> > 1/ I am working on geographical coordinates which makes necessary
> > that the X (longitude) and Y (latitude) units be represented with the
> > same distance on screen. This was obtained in the classical R plots
> > with plot.default(x,y, asp=1,...)  and then contour(..., add=T). When
> > I try aspect=1 with contour plot, I get a square but not at all the
> > aspect ratio I wish: 1 unit on X = one unit on Y = the same distance
> > on screen. What goes wrong?
>
> Well, aspect works as documented, so nothing goes wrong. The behaviour
> is just different from asp. You could try
>
> aspect = diff(range(y))/diff(range(x))
>
> and if your x and y are factors, aspect = "xy" should help. Maybe there
> should be a new option (perhaps aspect = "data") that should do this.
>
> > 2/ I would also be capable to project points and symbols on a
> > contourplot (the equivalent of points() and symbols() after plot()
> > and contour()), but can hardly guess from the help how to manage
> > with.
>
> You need to use a custom panel function (see the section on 'panel'
> in ?xyplot). There's no equivalent of symbols, unfortunately, but
> see ?panel.abline and ?lpoints.
>
> > 3/ I would also appreciate to manage the equivalent of
> > par(mfrow=c(2,2)) -or any other numbers of screens- and have a
> > "Trellis" plot in each of the sub-screens. It seems that contourplot
> > does not comply with and ignore the above parameters. Right or wrong?
>
> Right.
>
> > If so, which approach can solve this problem?
>
> See ?print.trellis. (Note that this also allows you to place trellis
> plots inside grid viewports, which maybe overkill for your use, but
> gives you more flexibility.)
>
> Deepayan




More information about the R-help mailing list