Edit 7 :
After quite a bit of help, I've been able to get a map that is getting close to the results I need. But I still need to have the state boundaries come through on the map, but I can't figure it out. In order to make a reproducible example that would be appropriate I need to link to the data set since the dput is so large.
To make things easy, I subset only three states, but where the boundary lines do not show up. I would like to be able to have the boundary lines come through the plot as white lines, like they are on the rest of the map. Thanks for your help.
Dataset :
https://www.dropbox.com/s/0evuvrlm49ab9up/PRISM_1895_db.csv?dl=0
Rep Code :
PRISM_1895_db <- read.csv("PRISM_1895_db.csv")
regions<- c("north dakota","south dakota","nebraska","kansas","oklahoma","texas","minnesota","iowa","missouri","arkansas", "illinois", "indiana", "wisconsin")
ggplot() +
geom_polygon(data=subset(map_data("state"), region %in% regions), aes(x=long, y=lat, group=group), col="white") +
geom_point(data = PRISM_1895_db2, aes(x = longitude, y = latitude, color = APPT), alpha = .5, size = 3.5)
Graph :
qmap
for this? Is there an existing plot you are trying to imitate? – Selfconsciouslibrary(maps); library(ggplot2); regions<- c("montana","wyoming","colorado","new mexico","north dakota","south dakota","nebraska","kansas","oklahoma","texas","minnesota","iowa","missouri","arkansas"); ggplot()+geom_polygon(data=subset(map_data("county"), region %in% regions), aes(x=long, y=lat, group=group, fill=region))
since it looks like you want county data. – Selfconsciousdb_map
object? Using those commands there's no "group" column generated. If you just change my example togeom_polygon(data=subset(map_data("county"), region %in% regions), aes(x=long, y=lat, group=group, fill=region), col="black")
will draw the borders in – Selfconsciousgeom_points
andgeom_polygon
. I suggest you do everything in one ggplot call and have each geom in a separate line. In my opinion, this improves readability. – SubprincipalPRISM_1895_test
. – Subprincipal