title: draw segment from angle despite changing aspect ratio
body: <p>I am trying to plot a table in R, with column names that are at an angle relative to the table. I would like to add lines to separate these column names, at the same angle as the text. However, it appears that the angle specified in the <code>text()</code> function is independent of the aspect ratio of the plot, whereas the angle I am using in the <code>segments()</code> function is dependent on the aspect ratio of the plot.</p>
  
  <p>Here is an example of what I mean:</p>
  
  <pre><code>nRows &lt;- 5
  nColumns &lt;- 3
  theta &lt;- 30
  
  rowLabels &lt;- paste('row', 1:5, sep='')
  colLabels &lt;- paste('col', 1:3, sep='')
  
  plot.new()
  par(mar=c(1,8,5,1), xpd=NA)
  plot.window(xlim = c(0, nColumns), ylim = c(0, nRows), asp = 1)
  text(labels = rowLabels, x=0, y=seq(from=0.5, to=nRows, by=1), pos=2)
  text(labels = colLabels, x = seq(from = 0.4, to = nColumns, by = 1), y = nRows + 0.1, pos = 4, srt = theta, cex = 1.1)
  segments(x0 = c(0:nColumns), x1 = c(0:nColumns), y0 = 0, y1 = nRows, lwd = 0.5)
  segments(x0 = 0, x1 = nColumns, y0 = 0:nRows, y1 = 0:nRows, lwd = 0.5)
  
  #column name separators, angle converted to radians
  segments(x0 = 0:(nColumns - 1), x1 = 1:nColumns, y0 = nRows, y1 = nRows + tan(theta * pi/180), lwd = 0.5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/kfg4K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfg4K.png" alt="enter image description here"></a></p>
  
  <p>However, if I want to be able to resize this plot window to my liking without specifying <code>asp</code>, the angles no longer match:</p>
  
  <pre><code>nRows &lt;- 5
  nColumns &lt;- 3
  theta &lt;- 30
  
  rowLabels &lt;- paste('row', 1:5, sep='')
  colLabels &lt;- paste('col', 1:3, sep='')
  
  plot.new()
  par(mar=c(1,8,5,1), xpd=NA)
  plot.window(xlim = c(0, nColumns), ylim = c(0, nRows))
  text(labels = rowLabels, x=0, y=seq(from=0.5, to=nRows, by=1), pos=2)
  text(labels = colLabels, x = seq(from = 0.4, to = nColumns, by = 1), y = nRows + 0.1, pos = 4, srt = theta, cex = 1.1)
  segments(x0 = c(0:nColumns), x1 = c(0:nColumns), y0 = 0, y1 = nRows, lwd = 0.5)
  segments(x0 = 0, x1 = nColumns, y0 = 0:nRows, y1 = 0:nRows, lwd = 0.5)
  
  #column name separators, angle converted to radians
  segments(x0 = 0:(nColumns - 1), x1 = 1:nColumns, y0 = nRows, y1 = nRows + tan(theta * pi/180), lwd = 0.5)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DoGxI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DoGxI.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to specify a set angle, such that the figure looks right when I resize the window?</p>