tags:

views:

71

answers:

1

I have a plot with many overlapping points (goes from 2-10). Adding jitter to the points makes it very noisy and unappealing. I like adding a alpha in the aesthetics. However, I'd like to have a legend where a reader can see how many points are overlapping for each of those transparencies. Is there such a way?

ggplot(data=mydata,aes(x=x,y=y)) + geom_point(size=3,shape=2,aes(alpha=1/3))

Let's say I use the above code. How would I incorporate a legend for the alpha?

A: 

Not exactly what you want, but how about geom_hex()?

If you don't discretize (bin) it, I think R would need to calculate the overlapped area and the number of overlappedness(sp?) (which would also depend on point size), and that sounds hard.

library(hexbin)

mydata <- data.frame(x = rnorm(100), y = rnorm(100))
ggplot(data=mydata,aes(x=x,y=y)) + geom_hex()
apeescape
Thanks so much. That is almost exactly what I want. If only I could turn the hexagons into circles...
Maiasaura
Good luck getting circles to tile a plane ;)
hadley
ha!I guess the next best thing to do is just use geom_point but create another count column and set that as size.
Maiasaura
or ?sunflowerplot for more discrete data
apeescape