Re: [R] lattice xyplot with bty=l

2007-09-05 Thread Patrick Drechsler
Deepayan Sarkar [EMAIL PROTECTED] writes:

 On 9/4/07, Patrick Drechsler [EMAIL PROTECTED] wrote:

 what is the correct way of removing the top and right axes
 completely from a lattice xyplot? I would like to have a plot similar
 to using the bty=l option for traditional plots.

 There is no direct analog (and I think it would be weird in a
 multipanel plot). 

I agree that this is not very useful for multipanel plots.

 Combining a few different features, you can do:

 library(grid)

 xyplot(1:10 ~ 1:10, scales = list(col = black, tck = c(1, 0)),
par.settings = list(axis.line = list(col = transparent)),
axis = function(side, ...) {
if (side == left)
 grid.lines(x = c(0, 0), y = c(0, 1),
default.units = npc)
else if (side == bottom)
 grid.lines(x = c(0, 1), y = c(0, 0),
default.units = npc)
axis.default(side = side, ...)
})

 -Deepayan

Thank you very much Deepayan, this is exactly what I was looking for!

Cheers,

Patrick

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] lattice xyplot with bty=l

2007-09-04 Thread Patrick Drechsler
Hi,

what is the correct way of removing the top and right axes
completely from a lattice xyplot? I would like to have a plot similar
to using the bty=l option for traditional plots.

An example:

--8---cut here---start-8---
rm(list=c(ls())) 
library(lattice)

y - 1:10
x - y

## Traditional plot:
plot(x, y, bty = l)

## Lattice plot 1:
xyplot(y ~ x,
   panel = function(x, y, ...){
 panel.xyplot(x, y, ...)
 panel.axis(side = c(left, bottom))
   }
   )

## Lattice plot 2:
xyplot(y ~ x,
   ## This just tries to remove all y axes:
   scales = list(y = list(draw = FALSE))
   )
--8---cut here---end---8---

Thankful for any pointers,

Patrick

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lattice xyplot with bty=l

2007-09-04 Thread Deepayan Sarkar
On 9/4/07, Patrick Drechsler [EMAIL PROTECTED] wrote:
 Hi,

 what is the correct way of removing the top and right axes
 completely from a lattice xyplot? I would like to have a plot similar
 to using the bty=l option for traditional plots.

There is no direct analog (and I think it would be weird in a
multipanel plot). Combining a few different features, you can do:

library(grid)

xyplot(1:10 ~ 1:10, scales = list(col = black, tck = c(1, 0)),
   par.settings = list(axis.line = list(col = transparent)),
   axis = function(side, ...) {
   if (side == left)
grid.lines(x = c(0, 0), y = c(0, 1),
   default.units = npc)
   else if (side == bottom)
grid.lines(x = c(0, 1), y = c(0, 0),
   default.units = npc)
   axis.default(side = side, ...)
   })

-Deepayan



 An example:

 --8---cut here---start-8---
 rm(list=c(ls()))
 library(lattice)

 y - 1:10
 x - y

 ## Traditional plot:
 plot(x, y, bty = l)

 ## Lattice plot 1:
 xyplot(y ~ x,
panel = function(x, y, ...){
  panel.xyplot(x, y, ...)
  panel.axis(side = c(left, bottom))
}
)

 ## Lattice plot 2:
 xyplot(y ~ x,
## This just tries to remove all y axes:
scales = list(y = list(draw = FALSE))
)
 --8---cut here---end---8---

 Thankful for any pointers,

 Patrick

 __
 R-help@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
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@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
and provide commented, minimal, self-contained, reproducible code.