我想添加一个包含多边形的shapefile到我的Choroplethr包创建的Choroplethr地图。创建了choropleth地图,代码如下:
choro=county_choropleth(Change, title= "WeeklyChange", state_zoom = continental_us,reference_map = F)+ scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1", "0"="snow","1"="greenyellow","2"="green","3"="green3"))
plot(choro)
gold= readShapePoly("Gold") gold_df= fortify(gold) land= ggplot(data= gold_df,aes(x=long, y= lat, group=group))+ geom_polygon(colour="gold3")
plot(gold)
这两个物体看起来都是正确的,但是我不能把黄金图样堆放在合奏图上。合唱图和黄金图
提前感谢!
发布于 2016-03-11 17:45:34
感谢阿里·兰斯坦帮助我。下面是添加多边形的代码
# Create Choropleth Map
`choro=county_choropleth(Change, title= "WeeklyChange",
state_zoom = continental_us,reference_map = F)+
scale_fill_manual(values=c("-3"="red4","-2"="red3","-1"="red1",
"0"="snow","1"="greenyellow","2"="green","3"="green3"))`
`#Import shapefile polygons
gold= readShapePoly("Gold")`
`#Create dataframe for ggplot
gold_df= fortify(gold)`
`#Combine Choropleth Map and shapefile dataframe
choro+geom_polygon(data= gold_df,aes(x=long, y= lat,group=group),fill="gold3")`https://stackoverflow.com/questions/35897647
复制相似问题