title: Plotting bar charts on map using ggplot2?
body: <p>I would like to produce a barplot for each location on a map using ggplot2,
  as was done by xingmowang with base graphics and a number of packages: </p>
  
  <p><a href="http://nzprimarysectortrade.wordpress.com/2011/10/02/let-r-fly-visualizing-export-data-using-r/" rel="noreferrer">http://nzprimarysectortrade.wordpress.com/2011/10/02/let-r-fly-visualizing-export-data-using-r/</a></p>
  
  <p><img src="https://i.stack.imgur.com/nTESY.png" alt="enter image description here"></p>
  
  <p>This is related to <a href="https://stackoverflow.com/questions/7793935/embedding-a-miniature-plot-within-a-plot">Embedding a miniature plot within a plot</a>.</p>
  
  <p>For the moment, the best I can do is match value to point size in a jittered point plot:  </p>
  
  <pre><code>require(ggplot2)
  require(maps)
  
  #Get world map info
  world_map &lt;- map_data("world")
  
  #Creat a base plot
  p &lt;- ggplot() + coord_fixed()
  
  #Add map to base plot
  base_world &lt;- p + geom_polygon(data=world_map,
                                 aes(x=long,
                                     y=lat,
                                     group=group))
  
  
  #Create example data
  geo_data &lt;- data.frame(long=c(20,20,100,100,20,20,100,100),
                         lat=c(0,0,0,0,0,0,0,0),
                         value=c(10,30,40,50,20,20,100,100),
                         Facet=rep(c("Facet_1", "Facet_2"), 4),
                         colour=rep(c("colour_1", "colour_2"), each=4))
  
  #Creat an example plot
  map_with_jitter &lt;- base_world+geom_point(data=geo_data,
                                              aes(x=long,
                                                  y=lat,
                                                  colour=colour,
                                                  size=value),
                                           position="jitter",
                                           alpha=I(0.5))
  
  #Add faceting
  map_with_jitter &lt;- map_with_jitter + facet_wrap(~Facet)
  
  map_with_jitter &lt;- map_with_jitter + theme(legend.position="none")
  
  print(map_with_jitter)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/8cQX1.jpg" alt="Example map plot with ggplot2"></p>
  
  <p>With an inelegant workaround:</p>
  
  <pre><code>subset_data &lt;- geo_data[geo_data$Facet=="Facet_1" &amp;
                            geo_data$long=="20",]
  subplot &lt;- qplot(data=subset_data,
                   x=colour,
                   y=value,
                   fill=colour,
                   geom="bar",
                   stat="identity")+theme(legend.position="none")
  
  print(base_world)
  print(subplot, vp=viewport((200+mean(subset_data$long))/400,(100+mean(subset_data$lat))/200 , .2, .2))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/JfcLS.jpg" alt="enter image description here"></p>