Trevor Davies
2014-Apr-10 03:27 UTC
[R] ggplot / ggmap: fixing geom_point size to break bins
Hello,
I'm been playing around trying to get some maps working in ggplot &
ggmap.
I have a series of maps I'm trying to make and I want to fix the bubble
area size of banana catches to the specified breaks. I.e so banana catches
of 2 will always be a specified size so when I make the next map, banana
caches of 2 will also have the same geom_point area size. I have quite a
range of catches (most 1-5, a few >500) so a simple proportional to value
won't work.
Thanks for the help. ~Trevor
Example code attached.
require(ggmap)
ns.coast = c(lon = -62, lat = 46)
ns.map = get_map(location = ns.coast, zoom = 6, color = "color")
data1 <- structure(list(X = c(300.5167, 300.7, 302.2167, 301.3, 302.6,
302), Y = c(46.5833, 45.5, 45.4, 44.7833, 44.95, 45.7333), catch c(1.1437908497,
0.9722222222, 1.0294117647, 2, 0.9722222222, 0.9943181818)), .Names
c("X",
"Y", "catch"), class = "data.frame", row.names =
c(92676L, 92689L,
92694L, 92700L, 92702L, 92704L))
p1 <- ggmap(ns.map, extent = "panel", maprange=FALSE)
p2 <- p1 + geom_point(data = data1,aes(x=(X-360),y=Y,size catch),alpha=.5)+
labs(size = "Banana's per
tow")+scale_size_area(breaks=c(0,1,2,5,10,20,50,100,500,1000))
[[alternative HTML version deleted]]