title: Transparent grid lines
body: <p>I want to create transparent lines with the grid package.</p>
  
  <p>This works (only for horizontal and vertical lines):</p>
  
  <pre><code>require(grid)
  grid.newpage()
  grid.rect(x=0.5, y=0.5, width=0, height=0.5, gp=gpar(col=rgb(1, 0, 0, .4)))
  </code></pre>
  
  <p>However, this doesn't:</p>
  
  <pre><code>grid.newpage()
  grid.lines(x=c(0.5, 0.5), y=c(0.25, 0.75), gp=gpar(col=rgb(1, 0, 0, .4)))
  </code></pre>
  
  <p>I tried this both in RStudio v0.97.237 and in RGui 2.15.2.</p>
  
  <p>UPDATE: when I put this second code chunk in a function, such as in the dothegrid() in the first answer below, it does work in RStudio, but only after a restart, of after clicking "Clear All" in RStudio's plot device pane.</p>
  
  <p>UPDATE2: now we're getting somewhere: It only works when clicking on "Clear All" in RStudio, followed by the grid.lines statement (WITHOUT the grid.newpage() statement)</p>