[R] Reverse axis in xyplot()
Arni Magnusson
arnima at u.washington.edu
Thu Sep 18 23:12:51 CEST 2003
Creating a plot with reverse Y axis is easy enough with traditional
graphics:
> x <- 1:3
> y <- 1:3
> plot(y~x, ylim=c(3,1))
+-----------+
1 | o |
| |
2 | o |
| |
3 | o |
+-----------+
1 2 3
But xyplot doesn't grasp my idea:
> xyplot(y~x, ylim=c(3,1))
+-----------+
3 | o |
| |
2 | o |
| |
1 | o |
+-----------+
1 2 3
Does anyone know how the reverse Y axis can be rendered with xyplot(),
perhaps using a customized panel function? I have tried post-processing
the trellis object elements, but with no luck. I have also tried the
xyplot(-y~x) workaround, but I don't know how to display the customized
labels.
Finally, I'm aware of the y<-ordered(y,rev(y)) workaround, but a solution
for the continuous case would be preferred.
Thanks in advance,
Arni
More information about the R-help
mailing list