title: Add text to plots created with a function in r
body: <p>I create a figure containing two plots using a function i.e.</p>
  
  <pre><code>data1&lt;-1:3
  
  basic&lt;-function(data1){
  par(mfrow=c(2,1))
  plot(data1)
  plot(data1)
  }
  
  basic(data1)
  </code></pre>
  
  <p>Now I want to add text to the plots without having to include it in the function. But I can only add text to the bottom plot (see below).</p>
  
  <pre><code>text(x=c(1.5,1.6,1.7),y=c(2,2.1,2.2), labels=c("X","Y","Z"))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bC37P.png" alt="enter image description here"></p>
  
  <p>How can I add text to the top plot outside of the function? (I have lots of figures I create using the same function but need to place slightly different text labels in slightly different positions on each one). Thanks for any advice.</p>