Skip to content
Prev 305980 / 398506 Next

lattice dotplot reorder contiguous levels

Is result3 what you are looking for?



test<-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), conc = c(2.32, 0.902,
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c("2",
"4", "12", "24", "96", "135", "167", "168", "169"), class = "factor")),
.Names = c("site",
"conc", "samp.time"), row.names = c(NA, 52L), class = "data.frame")

result0 <-
dotplot(samp.time~conc|site, data=test,
        scales=list(x=list(log=10), y = list(relation = "free")),
        layout=c(1,5), strip=FALSE, strip.left=TRUE
        )
result0


test$sample.time <- as.numeric(as.character(test$samp.time))

result1 <-
xyplot(sample.time ~ conc | site,
       data=test,
       scales=list(x=list(log=10), y = list(relation = "same")),
       layout=c(1,5), strip=FALSE, strip.left=TRUE,
       panel=panel.dotplot)
result1

result2 <-
update(result1, panel=function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.rug(y=y)
}
)
result2

trellis.par.get("superpose.line")
new.col <- c(trellis.par.get("superpose.line")$col, "darkgreen", "darkblue")
trellis.par.set(superpose.line=list(col=new.col),
                superpose.symbol=list(col=new.col))


result3 <-
xyplot(sample.time ~ conc | site,
                   groups=samp.time, pch=16,
                   data=test,
                   scales=list(x=list(log=10), y = list(relation =
"same"), alternating=1),
                   layout=c(1,5), strip=FALSE, strip.left=TRUE,
		   par.settings = list(clip = list(panel = "off")),
                   panel=function(x, y, ...) {
                     panel.xyplot(x, y, ...)
                     gg <- list(...)$groups
                     subs <- list(...)$subscripts
                     col=trellis.par.get("superpose.line")$col
                     panel.rug(y=unique(y),
col=unique(col[match(gg[subs], levels(gg))]))
                     for (uy in unique(y))
                      panel.axis(side="right", at=uy, outside=TRUE,
                                 text.col=col[match(uy, levels(gg))],
                                 line.col=col[match(uy, levels(gg))])
                 }
                   )
result3
On 9/20/12, maxbre <mbressan at arpa.veneto.it> wrote: