title: How to add number of observation to a box plot
body: <p>I'm trying to figure out how to add number of observation to my box plot .  The example in the package demonstrates how to add number of observation on box plot .but I need to write the number of observation on x axis  I'm going to make a reproducible example based on that.</p>
  
  <pre><code># function for number of observations 
  give.n &lt;- function(x){
   return(c(y = median(x)*1.05, label = length(x))) 
  # experiment with the multiplier to find the perfect position
  }
  
  
  # plot
  ggplot(mtcars, aes(factor(cyl), mpg, label=rownames(mtcars))) +
   geom_boxplot(fill = "grey80", colour = "#3366FF") +
   stat_summary(fun.data = give.n, geom = "text", fun.y = median) 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/P55GW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P55GW.png" alt="enter image description here"></a></p>