title: How to draw lines outside of plot area in ggplot2?
body: <p>I created this plot with <strong>ggplot2</strong>:</p>
  
  <p><img src="https://i.stack.imgur.com/jmnzc.jpg" alt="enter image description here"></p>
  
  <p>The outside lines need to correspond to the Y scale, (i.e the Y position of the lines for Text1 should be 100 and 85). The only way I can do it by drawing a blank plot to the right of the figure with the same scale as the barchart and then using annotate function to draw the lines. Another approach is to simply "manually" draw the lines with <code>grid.lines</code>, however the coordinates of <code>grid.lines</code> will not correspond to the Y scale of the plot.</p>
  
  <p>Is it possible to somehow draw these lines using a different approach? I assume it would have to be done with <code>grid.lines</code>. How could I pass Y coordindates of the barchart to <code>grid.lines</code>?</p>
  
  <p>Below is the minimal code used to create this figure:</p>
  
  <pre><code>library (ggplot2)
  test= data.frame(
    group=c(rep(1,6), rep(2,6)),
    subgroup=c( 1,1,1,2,2,2,1,1,1,2,2,2),
    category=c( rep(1:3, 4)),
    count=c( 10,80,10,5,90,5,  10,80,10,5,90,5   )
    )
  
  qplot(subgroup, 
        count, 
        data=test, 
        geom="bar", 
        stat="identity",
        fill =category,  
        facets =  .~ group,  width=0.9)+
        opts(legend.position="none",
             plot.margin = unit(c(0,9,2,0), "lines"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/WslAN.jpg" alt="enter image description here"></p>
  
  <p>How can I draw the lines to the right of the bars?</p>
  
  <p>I recently asked a question about drawing text outside of plot area in <strong>ggplot2</strong> and the solution was to use <code>gt$layout</code> and <code>grid.draw</code>. </p>
  
  <p><a href="https://stackoverflow.com/questions/10014187/displaying-text-below-the-plot-generated-by-ggplot">Displaying text below the plot generated by ggplot2</a></p>
  
  <p>Could the similar approach be used here? It is my understanding that annotation_custom is for text only and won't work with other graphical elements.
  Thanks</p>