1

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?

  • This is often done by specifying a partially transparent color. That way the "density" takes care of itself as plotted points overlap each other. In `R`, adding two digits to the hex-formatted color spec does the trick, e.g., `#FF0000 ---> #FF000088` – Carl Witthoft Jan 12 '14 at 15:55
  • The answer to [this question](http://stackoverflow.com/questions/20482822/bubble-plot-of-mine-quakes/20483156#20483156) shows how to plot points on a map with both color and size representing attributes of the data. If that doesn't do it for you, then please provide a link to your data. – jlhoward Jan 12 '14 at 19:05
  • I just answered this question [here at talkstats.com](http://www.talkstats.com/showthread.php/52675-ggplot2-contour-chart-plotting-concentrations?p=147651&viewfull=1#post147651) – Tyler Rinker Jan 12 '14 at 21:22

1 Answers1

0

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?

dlrts
  • 1