On Mon, Sep 14, 2009 at 3:55 PM, Jacob Wegelin <jacob.wege...@gmail.com> wrote: > 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?
Yes, and the reason is that grid does not have a grid.symbols() equivalent of symbols(). There are at least a couple of solutions (other than writing your own, which is easy for circles). The first is to use the gridBase package and use symbols(); there is an example at the end of the lattice book. The other is to use grid.symbols() in Paul's grImport package, which is much more general than symbols(). -Deepayan > (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.