If I make a scatterplot and several (e.g. 5) points lie on top of each other at a given x,y location I would like the plot symbol to be the number of superimposed points (e.g. "5"). Could someone please tell me how to do this in R? Thanks! Bill Simpson
>>>>> "BillS" == Simpson, William <William.Simpson at drdc-rddc.gc.ca> >>>>> on Fri, 3 Jan 2003 09:41:32 -0500 writes:BillS> If I make a scatterplot and several (e.g. 5) points BillS> lie on top of each other at a given x,y location I BillS> would like the plot symbol to be the number of BillS> superimposed points (e.g. "5"). Could someone please BillS> tell me how to do this in R? Thanks! (typical Martin's answer: ``You don't want what you are asking for''). No, seriously, I think using sunflowerplot() {as recommended by Chambers et al (1983) see help} is a bit better {-> ?sunflowerplot and examples} Other solutions to the same problem: b. use jittering jitter() c. use a ``2d density estimate'' and plot that 1) e.g. use image on a 2d histog 2) better use the "hexbin" package from bioconductor, this uses Dan Carr's Hexagons instead of squares and (some more ideas). Regards, Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <><
Bill - The behavior of the old-S function printer() was to count overstrikes in the way you describe. This was a non-graphics output device which would make a crude scatterplot using ascii characters (spaces and asterisks, for example) in response to "plot()" commands. I've looked for "printer" in help(Devices) and I don't find it. Non-graphics scatterplots probably haven't been implemented for R yet, and probably aren't a high priority. I think you'll have to count the overstrikes at each location yourself (hash the x-y coordinates), and then use the function text() to plot the appropriate symbol at each x-y location. - tom blackwell - university of michigan medical - ann arbor - On Fri, 3 Jan 2003, Simpson, William wrote:> If I make a scatterplot and several (e.g. 5) points lie on top of each other > at a given x,y location I would like the plot symbol to be the number of > superimposed points (e.g. "5"). Could someone please tell me how to do this > in R? Thanks! > > Bill Simpson > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >
OK Thanks Martin and Thomas I'll check sunflowerplot() Bill
Another is to use the function 'space' in the gregmisc package. It is used like 'jitter', but it determistically spreads (nearly) overlapping points out in either the x dimension so they don't overlap. See ?space in the gregmisc package for details. I've found this useful for situations where the the x and y data is discrete. FTIW, the gregmisc package also contains the function hist2d, which will create and plot a 2-dimensional histogram. -Greg> -----Original Message----- > From: Simpson, William [mailto:William.Simpson at drdc-rddc.gc.ca] > Sent: Friday, January 03, 2003 11:27 AM > To: 'r-help at stat.math.ethz.ch' > Subject: RE: [R] number plot symbol in scatterplot? > > > OK Thanks Martin and Thomas I'll check sunflowerplot() > > Bill > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >LEGAL NOTICE\ Unless expressly stated otherwise, this message is ... [[dropped]]