title: Adding convex hull to ggplot map
body: <p>I am trying to create a ggplot that includes coordinates, density, and a convex hull polygon.  </p>
  
  <p>The data is a set of twenty latitudinal and longitudinal points.</p>
  
  <p>This is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code># Data
  
  economy &lt;- read.csv("data-economy.csv", header=TRUE)
  
  # Convex hulls.
  
  hulls &lt;- ddply(economy, .(Latitude, Longitude), function(economy) 
              economy[chull(economy$Latitude, economy$Longitude), ])
  
  fig &lt;- ggplot(economy, aes(Latitude, Longitude, colour="black", fill="black")) + 
                geom_point() + 
                geom_density2d(alpha=.5) + 
                labs(x = "Latitude", y = "Longitude") + 
                geom_polygon(data=hulls, alpha=.2)
  
  fig</code></pre>
  </div>
  </div>
  </p>
  
  <p>The resulting plot looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/KrQwx.png" alt="economypolygon1"></p>
  
  <p>I've tried a few things, and I can't get the convex hull to include only the points with max latitude and longitude. I can get the shape that I want outside of ggplot by using this code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>X &lt;- economy
  chull(X)
  plot(X, cex = 0.5)
  hpts &lt;- chull(X)
  hpts &lt;- c(hpts, hpts[1])
  lines(X[hpts, ])</code></pre>
  </div>
  </div>
  </p>
  
  <p>The result that it gives me is this:</p>
  
  <p><img src="https://i.stack.imgur.com/1BEUm.png" alt="economypolygon2"></p>
  
  <p>How can I get the same shape as in R base in ggplot?</p>
  
  <p>Also, why when I change the color in my ggplot code, does it not change the plot?</p>