title: stat_density2d - What does the legend mean?
body: <p>I have a map done in R with <code>stat_density2d</code>. This is the code:</p>
  
  <pre><code>ggplot(data, aes(x=Lon, y=Lat)) + 
    stat_density2d(aes(fill = ..level..), alpha=0.5, geom="polygon",show.legend=FALSE)+
    geom_point(colour="red")+
    geom_path(data=map.df,aes(x=long, y=lat, group=group), colour="grey50")+
    scale_fill_gradientn(colours=rev(brewer.pal(7,"Spectral")))+
    xlim(-10,+2.5) +
    ylim(+47,+60) +
    coord_fixed(1.7) +
    theme_void()
  </code></pre>
  
  <p>And it produces this:</p>
  
  <p><a href="https://i.stack.imgur.com/9e57P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9e57P.png" alt="UK Map"></a></p>
  
  <p>Great. It works. However I do not know what the legend means. I did find this wikipedia page:</p>
  
  <p><a href="https://en.wikipedia.org/wiki/Multivariate_kernel_density_estimation" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Multivariate_kernel_density_estimation</a> </p>
  
  <p>And the example they used (which contains red, orange and yellow) stated:</p>
  
  <blockquote>
    <p>The coloured contours correspond to the smallest region which contains
    the respective probability mass: red = 25%, orange + red = 50%, yellow
    + orange + red = 75%</p>
  </blockquote>
  
  <p>However, using stat_density2d, I have 11 contours in my map. Does anyone know how stat_density2d works and what the legend means? Ideally I wanted to be able to state something like the red contour contains 25% of the plots etc. </p>
  
  <p>I have read this: <a href="https://ggplot2.tidyverse.org/reference/geom_density_2d.html" rel="nofollow noreferrer">https://ggplot2.tidyverse.org/reference/geom_density_2d.html</a> and I am still none the wiser.</p>