Re: [R] contourplot, xyplot, aspect ratio, mfrow

2004-05-02 Thread Deepayan Sarkar
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] contourplot, xyplot, aspect ratio, mfrow

2004-05-02 Thread Patrick Giraudoux
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 [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; Patrick Giraudoux [EMAIL PROTECTED]
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html