0

I am using ggplot2 to create a choropleth map. I am able to plot the map with different shaded based on the data frame, but I would like to label the state & the number of crimes on the state. I tried geom_text but it keeps saying "Error : geom_text requires the following missing aesthetics: x, y"

This is the code that I have for plotting choropleth

  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') 

I tried geom_text(data=crimeset,aes(label=state)) but I get the above error

Tinniam V. Ganesh
  • 1,979
  • 6
  • 26
  • 51
  • Well, where exactly did you want the `geom_text` to appear? You need to specify coordinates. You should provide some sample data to make your problem [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). If we can't run your code to see what the plot looks like, it's very difficult to help. – MrFlick Oct 13 '15 at 14:45
  • On top of the map. The map is automatically constructed given India shape file. Updated above question with details – Tinniam V. Ganesh Oct 13 '15 at 14:49

0 Answers0