The symbols function is base graphics which does not play nicely with lattice graphics (without extra work).
Here is one approximation that works with lattice: x <- runif(10) y <- rnorm(10) z <- runif(10, 1,5) library(lattice) library(TeachingDemos) # for panel.my.symbols and friends xyplot( y ~ x, panel=panel.my.symbols, symb=ms.polygon(250), inches=sqrt(z)/5 ) hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Jacob Wegelin > Sent: Monday, September 14, 2009 4:55 PM > To: r-h...@stat.math.ethz.ch > Subject: [R] symbols(x,y, circles=sqrt(N)) with lattice xyplot > > How would I create the following plot using lattice? > > symbols( combPsummary$pastRate, combPsummary$finRate, > circles=sqrt(combPsummary$N) ) > > The idea is to plot finRate vs pastRate using circles whose areas are > proportional to the number of people in each group. > > The following attempt does not really work: > > xyplot( > finRate ~ pastRate > , data=combPsummary > , panel=function( x, y, ...) { > panel.xyplot( x,y, type="n" ) > symbols( x , y, circles=sqrt(combPsummary$N)) > } > ) > > It apparently first draws a rectangle, i.e., the lattice panel, and > then inside that rectangle it draws the same thing that is drawn by > the symbols() command outside of a panel function. That is, it draws > another rectangle in addition to the desired circles, and it writes > its own axis labels. > > I didn't find "symbols" in the index of Deepayan's book. And I don't > think the xyplot help file deals with this either? I don't think there > is a "lsymbols" or "panel.symbols" function? > > (Bill Cleveland points out that the human eye does not interpret area > accurately, so that making the area of a circle proportional to sample > size may be a flawed approach. Thus I'd also be interested in any > comments on how one might best graphically display x, y, and sample > size in a single plot.) > > Thanks for any tips > > Jake Wegelin > > ______________________________________________ > 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. ______________________________________________ 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.