Bryan Hanson
2009-Sep-07 19:58 UTC
[R] xyplot {lattice} are different types possible for each panel?
Hello R Folks... Using the example below, I¹d like two of the panels to be plotted with type = ³p² but the third to be done with type = ³h². I can¹t use type = c(³p², ³p², ³h²) because this syntax applies all given types to every panel. I don¹t think I can use groups and distribute.type because these are intended for different styles of plotting within a single panel. As you can see, I tried to do a panel function following something I saw in the Lattice book, but this has no effect at all. Looks like it may have to be more elaborate, but I¹m stuck. Any suggestions appreciated! Thanks, Bryan ************* Bryan Hanson Professor of Chemistry & Biochemistry DePauw University, Greencastle IN USA y <- rnorm(100) x <- rnorm(100) names <- rep(c("Set 1", "Set 2", "Set 3"), 4) df <- data.frame(y = y, x = y, names = as.factor(names)) p <- xyplot(y ~ x | names, layout = c(1, 3), panel = function(...) { panel.xyplot(...) if (panel.number() == 1) type = "h" }) plot(p) [[alternative HTML version deleted]]
baptiste auguie
2009-Sep-07 20:19 UTC
[R] xyplot {lattice} are different types possible for each panel?
Hi, Something like this perhaps, p <- xyplot(y ~ x | names, layout = c(1, 3), panel = function(...,type="p") { if (panel.number() == 1) { panel.xyplot(...,type = "h") } else { panel.xyplot(...,type = type) } }) plot(p) HTH, baptiste 2009/9/7 Bryan Hanson <hanson@depauw.edu>> Hello R Folks... > > Using the example below, Iąd like two of the panels to be plotted with type > = łp˛ but the third to be done with type = łh˛. I canąt use type = c(łp˛, > łp˛, łh˛) because this syntax applies all given types to every panel. I > donąt think I can use groups and distribute.type because these are intended > for different styles of plotting within a single panel. As you can see, I > tried to do a panel function following something I saw in the Lattice book, > but this has no effect at all. Looks like it may have to be more > elaborate, > but Iąm stuck. Any suggestions appreciated! > > Thanks, Bryan > ************* > Bryan Hanson > Professor of Chemistry & Biochemistry > DePauw University, Greencastle IN USA > > > y <- rnorm(100) > x <- rnorm(100) > names <- rep(c("Set 1", "Set 2", "Set 3"), 4) > df <- data.frame(y = y, x = y, names = as.factor(names)) > p <- xyplot(y ~ x | names, > layout = c(1, 3), > panel = function(...) { > panel.xyplot(...) > if (panel.number() == 1) type = "h" > }) > > plot(p) > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@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 ______________________________ [[alternative HTML version deleted]]