有没有办法在使用ggplot2绘制等值区域图时标记数据

时间:2015-10-13 14:39:55

标签: r ggplot2 choropleth

我正在使用ggplot2创建一个等值区域图。我能够根据数据框架绘制具有不同阴影的地图,但我想标记状态&国家犯罪的数量。我尝试了geom_text,但它一直在说"错误:geom_text需要以下缺少美学:x,y"

这是我用于绘制等值线的代码

  ind <- readShapeSpatial("./IND_adm/IND_adm1.shp")
  ind <- fortify(ind, region = "NAME_1")

  # read in data frame with number of crimes per Year.
  #Plot choropleth map
  ggplot(data = crimeSet)  + 
  geom_map(data = crimeSet, aes(map_id = state, fill = yearlyCrimes),   map = ind) + 
  expand_limits(x = ind$long, y = ind$lat) +        
  scale_fill_gradient2(low = "pink",                                                                           
                         mid = "red", midpoint = mid, high = "brown", limits = c(n, m)) +
   ggtitle('Total Crimes') 

我尝试了geom_text(data=crimeset,aes(label=state)),但我收到了上述错误

0 个答案:

没有答案