Question

I have the x and y coordinates for a whole bunch of mouse clicks. A simple scatterplot of these coordinates is below.

enter image description here

As you can see, obviously, there seems to be 3 areas where the clicks are relatively more concentrated. I would like to plot these clicks in a way that reflects the relative concentration of the clicks - e.g., circles in an area with a high concentration of clicks are relatively larger or have darker colors. Obviously a simple scatterplot does not show that. I tried following the following post, but result is not what I want.

So any suggestion would be greatly appreciated.

Était-ce utile?

La solution

Any of these work for you?

## scatter
plot(quakes$long, quakes$lat)

enter image description here

library(hexbin)
plot(hexbin(quakes$long, quakes$lat))

enter image description here

library(ggplot2)
ggplot(quakes, aes(x = long, y = lat)) + stat_density2d(aes(alpha = ..level..), geom = "polygon")

enter image description here

ggplot(quakes, aes(x = long, y = lat)) + stat_density2d(aes(fill = ..density..), geom = "tile", contour = FALSE)

enter image description here

library(MASS)
filled.contour(kde2d(quakes$long, quakes$lat))

enter image description here

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top