title: How to shade a region under a horizontal line transparently using ggplot2?
body: <p>This is the original image. </p>
  
  <p><img src="https://i.stack.imgur.com/yhmGK.png" alt="Original Image"></p>
  
  <p>This is the code i used to produce the above image.</p>
  
  <pre><code>## Employees Wise Sales Report: MAY 2014-LYNDA Best Visualization Assignment
  setwd('d:/dataset/lynda')
  empwisedata=read.csv('income.csv',header=T,sep=",")
  names(empwisedata)
  attach(empwisedata)
  
  Minimum=c(min(Person1),min(Person2),min(Person3),min(Person4),min(Person5))
  Average=c(mean(Person1),mean(Person2),mean(Person3),mean(Person4),mean(Person5))
  Maximum=c(max(Person1),max(Person2),max(Person3),max(Person4),max(Person5))
  attach(Average)
  
  library(ggplot2)
  library(reshape2)
  df = melt(data.frame(Minimum,Average,Maximum,Employees=c("Person1", "Person2","Person3","Person4","Person5")),variable.name="IncomeLevels")
  df$Employees&lt;-factor(df$Employees,levels = df$Employees[order(Average)])
  
  p=ggplot(df, aes(Employees, value, fill=IncomeLevels)) +   geom_bar(position="dodge",stat="identity")
  
  p + geom_hline(yintercept=mean(Average))+scale_fill_manual(values=c("red","orange","dark green"))+labs(size= "Nitrogen", x = "Employees of ACME Widgets",y = "Income in USD", title = "ACME WIDGETS :: Employees Wise Sales Report-MAY 2014 ")
  </code></pre>
  
  <p>I would like to fill the color under the horizontal line in the graph. i had tried geom_rect by modifying the last line of above code as follows.</p>
  
  <pre><code>p+geom_hline(yintercept=mean(Average)) + scale_fill_manual(values=c("red","orange","dark green"))+labs(size= "Nitrogen", x = "Employees of ACME Widgets",y = "Income in USD", title = "ACME WIDGETS :: Employees Wise Sales Report-MAY 2014 ") + geom_rect(xmin=0,xmax=200,ymin=0,ymax=mean(Average),fill="blue")
  </code></pre>
  
  <p>and got the following image.</p>
  
  <p><img src="https://i.stack.imgur.com/QAtAq.png" alt="enter image description here"></p>
  
  <p>I dont need dark blue. I need transparency so that average bars (Yellow coloured) also viewed. I had tried with different alpha levels too. But nothing works. Your help is appreciated.</p>
  
  <p>Solution:
  i had modified the last line of the code as per the advice of LukeA. The code is </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>p+geom_hline(yintercept=mean(Average))+scale_fill_manual(values=c("red","orange","dark green"))+labs(size= "Nitrogen", x = "Employees of ACME Widgets",y = "Income in USD", title = "ACME WIDGETS :: Employees Wise Sales Report-MAY 2014 ")+  annotate("rect", xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = mean(Average), fill = "blue", alpha = .1, color = NA)</code></pre>
  </div>
  </div>
  </p>
  
  <p>and got the desired output plot as mentioned below.
  <img src="https://i.stack.imgur.com/RbRjF.png" alt="enter image description here"></p>
  
  <p>Thank you all.</p>