Hi All, I have a four panel xyplot. I wish to plot each point as an open or filled circle depending on the value of an indicator variable. I assume I need to use panel.superpose(), but I can't figure out the syntax from lattice documentation. Running R 2.1 under Mac OS X 10.4.2. Any suggestions would be appreciated. Nathan Nathan Leon Pace, MD, MStat University of Utah Salt Lake City, UT 84132 Office: 801.581.6393 Fax: 801.581.4367 Cell: 801.205.1019 Pager: 801.291.9019 Home: 801.467.2925 [[alternative HTML version deleted]]
On 9/28/05, Nathan Leon Pace, MD, MStat <N.L.Pace at m.cc.utah.edu> wrote:> Hi All, > > I have a four panel xyplot. I wish to plot each point as an open or > filled circle depending on the value of an indicator variable. > > I assume I need to use panel.superpose(), but I can't figure out the > syntax from lattice documentation.Not directly. You do need to change the plotting character (pch). Here are two ways to do it (the second is longer but recommended): dotplot(variety ~ yield | site, data = barley, groups = year, pch = c(1, 16)) dotplot(variety ~ yield | site, data = barley, groups = year, auto.key = TRUE, par.settings = list(superpose.symbol = list(pch = c(1, 16)))) Deepayan
> library(lattice) > temp1 <- data.frame(x = runif(100), y = runif(100), ind1 = sample(1:4,100, replace = TRUE), ind2 = sample(1:4, 100, replace = TRUE))> xyplot(y~x |ind1, groups = ind2, data = temp1, pch = c(1, 2, 3, 16))You don't even need to tell it to use panel.superpose -- using "groups" tells it (try it with & without and see!). The pch values are set by group (here, value of ind2). It might be more elegant to use trellis.par.set to set the pch values, but I'm lazy. (It seems to have the desired effect -- try subsetting on ind2, and you get a subset of the values.) Hope this helps, Matt Wiener -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nathan Leon Pace, MD, MStat Sent: Wednesday, September 28, 2005 4:02 PM To: r-help at stat.math.ethz.ch Cc: Nathan Leon Pace, MD, MStat Subject: [R] xyplots Hi All, I have a four panel xyplot. I wish to plot each point as an open or filled circle depending on the value of an indicator variable. I assume I need to use panel.superpose(), but I can't figure out the syntax from lattice documentation. Running R 2.1 under Mac OS X 10.4.2. Any suggestions would be appreciated. Nathan Nathan Leon Pace, MD, MStat University of Utah Salt Lake City, UT 84132 Office: 801.581.6393 Fax: 801.581.4367 Cell: 801.205.1019 Pager: 801.291.9019 Home: 801.467.2925 [[alternative HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Thanks for suggestions on plotting different symbols in an xyplot by Sarkar and Wiener in answer to my question: "I have a four panel xyplot. I wish to plot each point as an open or filled circle depending on the value of an indicator variable." Wiener: You don't even need to tell it to use panel.superpose -- using "groups" tells it (try it with & without and see!). The pch values are set by group (here, value of ind2). It might be more elegant to use trellis.par.set to set the pch values, but I'm lazy. (It seems to have the desired effect -- try subsetting on ind2, and you get a subset of the values.) Hope this helps, Sarkar: Not directly. You do need to change the plotting character (pch). Here are two ways to do it (the second is longer but recommended): dotplot(variety ~ yield | site, data = barley, groups = year, pch = c (1, 16)) dotplot(variety ~ yield | site, data = barley, groups = year, auto.key = TRUE, par.settings = list(superpose.symbol = list(pch = c(1, 16)))) A related question: My xyplot is essentially a time series (up-and-down experimental design). Thus I need to connect the points sequentially regardless of the group value. With the groups argument, type = 'b' gives two lines - one for each group. Any more suggestions? Thanks, Nathan