title: R Plot : Size of the legend box with legend(), difference with RStudio
body: <p>I usually use R Studio when I need to write some code in R. But as soon as I want to make plots with a legend, I switch to the R Gui because the legend box from RStudio is different and unpleasant for me.</p>
  
  <p>Let me explain with an example:</p>
  
  <pre><code>sigma &lt;- (1:7000)/10000
  
  ratioMSY &lt;- 1 - 5.26 * sigma^2
  plot(sigma, ratioMSY, type="l", ylab="MSY(sigma^2)/MSY(0)", ylim=c(0,1), 
   lty=2, cex.lab=1.5, bty="n", cex.axis=1.5, lwd=3)
  
  par(new=T)
  ratioMSY &lt;- 1 - 2.78 * sigma^2
  plot(sigma, ratioMSY, type="l", ylab="MSY(sigma^2)/MSY(0)", ylim=c(0,1), lty=1, 
   cex.lab=1.5, bty="n", cex.axis=1.5, lwd=3)
  
  par(new=T)
  ratioMSY &lt;- 1 - 1.96 * sigma^2
  plot(sigma, ratioMSY, type="l", ylab="MSY(sigma^2)/MSY(0)", ylim=c(0,1), lty=3, 
   cex.lab=1.5, bty="n", cex.axis=1.5, lwd=3)
  
  legend(0,0.4,c("r = 0.1","r = 0.2","r = 0.3"), lty=c(2,1,3), cex=1.5)
  </code></pre>
  
  <p>Now I do it with RStudio and with RGui.</p>
  
  <p><em>With RStudio:</em></p>
  
  <p><img src="https://i.stack.imgur.com/leNxn.png" alt="enter image description here"></p>
  
  <p><em>With RGui:</em></p>
  
  <p><img src="https://i.stack.imgur.com/B4XBE.png" alt="enter image description here"></p>
  
  <p>See the difference ? In fact, the legend with RStudio has far two big spaces between each lines. I can solve it by using <code>y.intersp = 0.5</code> but it doesn't seem <em>natural</em> because I would do it each time I make plots, and the box stays big (only the spaces between the lines are reduced, not the spaces above and below the lines).
  I have tried almost all options of the <code>legend</code> function, without success. The <code>cex</code> option doesn't solve the problem.</p>
  
  <p>I didn't find anything on Google, and this is the first time I ask a question on StackOverflow, so I hope it will be ok. </p>