title: Plot legend problems using R. Help removing excessive white space in legend box
body: <p>I am creating a plot of some hydrology data and I am having trouble with the legend. The legend has a large amount of blank space around the text. I have tried using <code>par(mar= list)</code>, <code>cex</code>, <code>x.intersp</code>, and anything else I could find with no luck. I can't post images yet, but there is a link below. This is all of the code I am using to create the plot and legend. The <code>abline()</code> below indicates the mean value of the data and that is what I am putting in the legend. I have researched on the site and I can make it work using <code>mtext()</code> or legend(no bg or box) and <code>rect()</code>, but it seems like I am missing something. I am fairly new to R, but I have written code in the past. I am using RStudio version 0.99.903 and R version 3.2.2.</p>
  
  <pre><code>plot(dataFile$time_s,dataFile$w_cmps, type = "l",col="grey50", 
       xlim = c(0,18.5), ylim = c(-7,7), xlab = "Time (s)", ylab = "w (cm/s)", 
       main = "Vertical Velocity", xaxt="n")
  
  axis(side = 1, at = c(0,2,4,6,8,10,12,14,16,18), 
       labels = c(0,2,4,6,8,10,12,14,16,18))
  
  abline(h = mean_w, col = "black", lty = 3, lwd = 4)
  
  legend("bottomleft","Mean w", lty = 3, col = "red", 
         xjust = 1, cex = 1, bg = "grey75", trace = TRUE, ncol = 1, xpd = NA, 
         seg.len = 1, y.intersp = 0.25, x.intersp = 0.25)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SEb6a.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SEb6a.jpg" alt="enter image description here"></a></p>