I'm trying to produce a nice bubble plot overlaid on top of a
basemap of the US (i could import a shapefile if that is preferred but
i've been using the R basemaps.
Using this code below, that i adapted from another stack overflow
bubble plot in R using satellite map), i am able to overlay a
bubble plot on a map of the US. However this renders very slowly, the
extent is too tight, it is bounded in a box, i'm not able to add other
layers to the plot from what i can tell, and the base map is thick and
not visually clean.
xy <- myData[,c("long", "lat")]
nl <- getData('GADM', country="USA", level=1) #raster data, format
nl <- gSimiplify(nl, tol=0.01, topologyPreserve=TRUE)
# coercing the polygon outlines to a SpatialLines object
spl <- list("sp.lines", as(nl, "SpatialLines"))
SPDF <- SpatialPointsDataFrame(coords=xy, data=myData)
coordinates(myData) <- c("lat", "long")
projection(SPDF)<- "+proj=longlat +ellps=WGS84 +datum=WGS84
coordinates(SPDF)[1:5,] #retrieves spatial coordinates form the
bubble(SPDF, "pop", sp.layout=spl, main="This is It!")
I can draw a nice basemap using this code. I add points to the map
but they are not sized by the pop column in my data. And i can add
additional layers to this map. But can i control the size of the
points and the symbol itself like i can using a bubble plot?
map(database= "world", ylim=c(45,90),
coord <- mapproject(myData$lon, myData$lat,
proj="gilbert",orientation=c(90, 0, 225))
points(coord, pch=20, cex=1.2, col="red")
Can anyone please guide me towards the best way to plot a bubble
map in R where i can adjust the fill and outline of the symbols in the
bubble map, And i can add a clean basemap, that i can a) control the
colors of (fill and lines) and b) add additional layers to (for
instance another shapefile layer).
Thank you in advance for any advice.