[R] lattice shingle plot axis annotation

baptiste auguie baptiste.auguie at googlemail.com
Thu Jul 30 19:23:34 CEST 2009


Hi,

Chapter 8 of the lattice book has some examples (you can see the code
and figures on r-forge). Perhaps you could try something like this,


d = data.frame(x=1:10,y=1:10,f=sample(letters[1:2],10,repl=T))

axis.custom = function(side, ...){
	
	if(side == "bottom")
	switch(panel.number(),
	'1' = panel.axis(side="bottom",outside=TRUE, at = c(4,6)),
	'2' = panel.axis(side="bottom",outside=TRUE, at = c(2,8),
labels=letters[1:2], rot=rep(0,2)))
}
	
xyplot(y~x|f, d, axis=axis.custom)


HTH,

baptiste

2009/7/30 Armin Goralczyk <agoralczyk at gmail.com>:
> Hello (R-)Experts
>
> I hope someone can help with this problem concerning axis annotation
> of a lattice shingle plot. I want a plot with three shingles to
> display some laboratory value over time. In the first panel over the
> first few days, then in the next panel some months, and in the last
> panel some years. In the following minimal example the axis annotation
> will be in days, but I'd like to have days in the fisrt panel, months
> in the second panel and years in the third panel. Is it possible?
>
> pod <- seq(1, 5000, 5)
> test <- data.frame(pod=pod,
>                   val=rep(c(1,2,4,8), length=length(pod)),
>                   g=rep(c('A', 'B'), length=length(pod)))
> shingle.pod <- shingle(test$pod, intervals = rbind(c(0, 20), c(20, 180),
>                                c(220, 6000)))
> test.plot <- xyplot(val ~ pod | shingle.pod,
>                    data = test,
>                    groups = test$g,
>                    scales = list(x = "free",
>                    y = list(relation = "same", log = 2)),
>                    between = list(x = 0.5),
>                    panel = function(x, y, ...) {
>                        panel.grid(h = -1, v = -1, lwd = 1)
>                        panel.superpose(x, y, ...)
>                    },
>                    type = c('b')
>                    )
> plot(test.plot)
>
> (this plot doesn't look good, I know, it's just and example)
> Thank you
> --
> Armin Goralczyk
> --
> http://www.gwdg.de/~agoralc
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list