简体   繁体   中英

R scatterplot colored by density

I am creating a plot of GPS traces. That is, I want a plot that has a map as base layer (working with ggmap) and ontop of the map I plot all the points (lat/lon) (works also with geom_point). Now what is left, is the color of all those point that I want to represent the density of the points. I experimented with density2d stat, which gives me a color with color=..level.. but then also modifies the position of my point and does not show all points. I do want to plot all the points with a color derived from the density. How would I do this?

ok the hint to alpha values did what I want, if I add my points twice, first in black and then another time in red with some small alpha

brauns <- get_map(location,zoom = 11, source = "cloudmade", maptype = 118540, api_key = apikey)
bmap <- ggmap(brauns,darken= c(0.1,"white"))
bmap <- bmap + geom_point(data = knime.in, aes(x = MAPPED_LON, y = MAPPED_LAT), size = 1)
bmap <- bmap + geom_point(data = knime.in, aes(x = MAPPED_LON, y = MAPPED_LAT),col="red",alpha=0.07, size = 1)

Now, can you think of a way to add a legend to it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM