title: Arranging arrows between points nicely in ggplot2
body: <p>(note - this is the same piece of work as <a href="https://stackoverflow.com/questions/14647794/using-multiple-size-scales-in-a-ggplot">using multiple size scales in a ggplot</a>, but I'm asking a different question) </p>
  
  <p>I'm trying to construct a plot which shows transitions from one class to another. I want to have circles representing each class, and arrows from one class to another representing transitions.</p>
  
  <p>I'm using geom_segment with arrow() to draw the arrows. Is there any way to:</p>
  
  <ul>
  <li>make the arrows stop before they reach the circles</li>
  <li>adjust the position so that if there is an arrow in both directions, they are "dodged" rather than overlapping.</li>
  </ul>
  
  <p>I couldn't get position="dodge" to do anything useful here.</p>
  
  <p>As an example:</p>
  
  <pre><code>library(ggplot2)
  points &lt;- data.frame( x=runif(10), y=runif(10),class=1:10, size=runif(10,min=1000,max=100000) )
  trans &lt;- data.frame( from=rep(1:10,times=10), to=rep(1:10,each=10), amount=runif(100)^3 )
  trans &lt;- merge( trans, points, by.x="from", by.y="class" )
  trans &lt;- merge( trans, points, by.x="to", by.y="class", suffixes=c(".to",".from") )
  ggplot( points, aes( x=x, y=y ) ) + geom_point(aes(size=size),color="red",shape=1) + 
      scale_size_continuous(range=c(4,20)) +
      geom_segment( data=trans[trans$amount&gt;0.6,], aes( x=x.from, y=y.from, xend=x.to, yend=y.to ),lineend="round",arrow=arrow(),alpha=0.5, size=0.3)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Fhui4.png" alt="Example graph"></p>