[R] lattice xyplot with bty="l"

Patrick Drechsler patrick at pdrechsler.de
Wed Sep 5 12:43:02 CEST 2007


"Deepayan Sarkar" <deepayan.sarkar at gmail.com> writes:

> On 9/4/07, Patrick Drechsler <patrick at pdrechsler.de> 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



More information about the R-help mailing list