title: ggplot2: How to change the width of boxplots according to another variable?
body: <p>I created a boxplot showing the dispersal distance <code>$dist</code> of some species <code>$spe</code>, and I would like the width of the boxes to be proportional to the density of regeneration of these species. I used "varwidth" and weight aesthetic as shown below, but this is still not correct, as it is still proportional to the number of observations and not only to the density of regeneration...</p>
  
  <p>(for the density, I calculated the proportion for each species, so it goes from 10 to 100. It is given in the column <code>data_dist2$prop2</code>) </p>
  
  <pre><code>p &lt;- ggplot(data_dist2, aes(x = reorder(spe, prop2), y = dist)) + 
    coord_flip() + 
    geom_boxplot(varwidth = TRUE, alpha=0.3, aes(weight=data_dist2$prop2), fill='grey10')
  </code></pre>
  
  <p>Would you have any idea how to make the boxplot exactly proportional to my <code>prop2</code> column?</p>
  
  <p>Reproductive example :</p>
  
  <pre><code>structure(list(spe = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
  3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L), .Label = c("Abies concolor", "Picea abies", "Sequoia semp."
  ), class = "factor"), dist = c(0, 0, 3, 3, 4, 4, 25, 46, 59, 
  113, 113, 9, 12, 12, 12, 15, 22, 22, 22, 22, 35, 35, 36, 49, 
  85, 85, 90, 5, 5, 1, 1, 8, 13, 48, 48, 52, 52, 52, 65, 89), prop2 = c(92.17, 
  92.17, 92.17, 92.17, 92.17, 92.17, 92.17, 92.17, 92.17, 92.17, 
  92.17, 10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 
  10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 10.9, 100, 100, 100, 100, 
  100, 100, 100, 100, 100, 100, 100, 100, 100)), row.names = c(NA, 
  -40L), class = "data.frame")
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote>