title: Adjusting visualization of igraph plot
body: <p>Following the discussion <a href="https://stackoverflow.com/questions/48549137/visualizing-an-association-btw-two-discrete-variables-via-diagram-in-r">here</a>, I am using the <code>igraph</code> to visualize the association between the two variables (<code>s</code> and <code>g</code>).</p>
  
  <p>In shell:</p>
  
  <pre><code>$ cat file
  s   g
  s1  foo bar
  s2  foo bar baz qux
  s99 foo
  s9999   foo bar baz qux
  s99999  foo
  s999999 foo
  </code></pre>
  
  <p>In <code>R</code>:</p>
  
  <pre><code>m &lt;- as.matrix(read.table(file="~/path_to_file/file", sep="\t", header=T))
  g &lt;- graph_from_edgelist(m)
  V(g)$type &lt;- bipartite.mapping(g)$type
  coords &lt;- layout_as_bipartite(g)
  plot.igraph(g, layout = -coords[,2:1],
      vertex.shape="rectangle",
      vertex.size=10,
      vertex.size2=1,
      vertex.color=NA,
      vertex.frame.color=NA,
      vertex.label.color="black",
      vertex.label.family="sans",
      edge.label.color="white",
      edge.arrow.mode=0,
      edge.width=3,
      asp=5)
  </code></pre>
  
  <p>However, the resulting visualization has the vertex labels and the edges overlapping, making the former difficult to read. </p>
  
  <p><a href="https://i.stack.imgur.com/cWeiP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWeiP.png" alt="enter image description here"></a></p>
  
  <p>I would like to adjust the R code such that all vertex labels are moved away from the vertex center (i.e., vertex labels of <code>s</code> moved to left, vertex labels of <code>g</code> moved to right) and that all vertex labels are left-aligned (and not centered, as is the default case).</p>
  
  <p>Can I do that via <code>igraph</code> and if so, how? (If that were not possible, which alternative visualization strategy in <code>R</code> would you suggest?)</p>
  
  <p>--</p>
  
  <p><strong>EDIT 1</strong>:
  A working solution would be able to handle a file with numerous verteces, such as <code>file2</code>:</p>
  
  <p>In shell:</p>
  
  <pre><code>$ cat file2
  s   g
  foo1    bar01 baz qux
  foo2    bar1 baz qux
  foo3    bar1 baz qux
  foo4    bar1 baz qux
  foo5    bar1 baz qux
  foo6    bar1 baz qux
  foo7    bar1 baz qux
  foo8    bar1 baz qux
  foo9    bar1 baz qux
  foo10   bar1 baz qux
  foo11   bar02 baz
  foo12   bar2 baz
  foo13   bar2 baz
  foo14   bar2 baz
  foo15   bar2 baz
  foo16   bar2 baz
  foo17   bar2 baz
  foo18   bar2 baz
  foo19   bar2 baz
  foo20   bar2 baz
  foo21   bar03 baz baz qux
  foo22   bar3 baz baz qux
  foo23   bar3 baz baz qux
  foo24   bar3 baz baz qux
  foo25   bar3 baz baz qux
  foo26   bar3 baz baz qux
  foo27   bar3 baz baz qux
  foo28   bar3 baz baz qux
  foo29   bar3 baz baz qux
  foo30   bar3 baz baz qux
  foo31   bar04 baz baz qux quux
  foo32   bar4 baz baz qux quux
  foo33   bar4 baz baz qux quux
  foo34   bar4 baz baz qux quux
  foo35   bar4 baz baz qux quux
  foo36   bar4 baz baz qux quux
  foo37   bar4 baz baz qux quux
  foo38   bar4 baz baz qux quux
  foo39   bar4 baz baz qux quux
  foo40   bar4 baz baz qux quux
  foo41   bar05 baz qux quux
  foo42   bar5 baz qux quux
  foo43   bar5 baz qux quux
  foo44   bar5 baz qux quux
  foo45   bar5 baz qux quux
  foo46   bar5 baz qux quux
  foo47   bar5 baz qux quux
  foo48   bar5 baz qux quux
  foo49   bar5 baz qux quux
  foo50   bar5 baz qux quux
  foo51   bar06 baz qux
  foo52   bar6 baz qux
  foo53   bar6 baz qux
  foo54   bar6 baz qux
  foo55   bar6 baz qux
  foo56   bar6 baz qux
  foo57   bar6 baz qux
  foo58   bar6 baz qux
  foo59   bar6 baz qux
  foo60   bar6 baz qux
  foo61   bar07 baz qux quux
  foo62   bar7 baz qux quux
  foo63   bar7 baz qux quux
  foo64   bar7 baz qux quux
  foo65   bar7 baz qux quux
  foo66   bar7 baz qux quux
  foo67   bar7 baz qux quux
  foo68   bar7 baz qux quux
  foo69   bar7 baz qux quux
  foo70   bar7 baz qux quux
  </code></pre>
  
  <p>Even when implementing the improvements suggested by <a href="https://stackoverflow.com/users/4752675/g5w">G5W</a> (i.e., adjusting the vertex width for each vertex individually; see variable <code>Size1</code>), the resulting graph remains difficult (or almost impossible) to visualize. Specifically, there does not appear to be a <strong>sweetspot</strong> between the aspect ratio, the vertex height and the vertex width.</p>
  
  <p>In <code>R</code>:</p>
  
  <pre><code>Size1 = 12*nchar(V(g)$name)
  plot.igraph(g, layout = -coords[,2:1],
      vertex.shape="rectangle",
      vertex.size=Size1,
      vertex.size2=5,
      vertex.color=NA,
      vertex.frame.color="green",
      vertex.label.color="black",
      vertex.label.family="sans",
      edge.label.color="white",
      edge.arrow.mode=0,
      edge.width=3,
      asp=2.5
      )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1SjFj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1SjFj.png" alt="enter image description here"></a></p>