title: Color bar legend for values on vertices of igraph in R
body: <p>I am new in R and I am starting to work on graph visualization over there using igraph. The example below create a simple network of 10 vertices and color them according to color values (which in this case for simplicity I set up to be the same as ids of vertices).</p>
  
  <pre><code>library(igraph)
  vertices &lt;- 1:10
  first &lt;- 1:10
  second &lt;- c(2:10,1)
  edges = cbind(first,second)
  color = 1:10
  net = graph_from_data_frame(edges,vertices=vertices ,directed=F )
  V(net)$color = color
  plot(net)
  </code></pre>
  
  <p>However from this plot it is not clear which colors correspond to
  which numbers:</p>
  
  <p><a href="https://i.stack.imgur.com/kUvXB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kUvXB.png" alt="enter image description here"></a></p>
  
  <p>To deal with this I have tried to create various
  legends I was able to find in the documentation and online. Take for
  instance the code below:</p>
  
  <pre><code>legend("bottom", legend=levels(as.factor(color)), bty = "n", cex =
  1.5, pt.cex = 3, pch=20, col = color , horiz = FALSE , inset = c(0.1,
  -0.3)
  </code></pre>
  
  <p>But in this case, the result is messy, obscure the picture, and do not provide a continuous color bar that would map the range of values on the nodes to color spectrum. Other options I was able to find are not better.</p>
  
  <p><a href="https://i.stack.imgur.com/zBslU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBslU.png" alt="enter image description here"></a></p>
  
  <p>Do you know how to make a legend in a form of a continuous color bar placed below or to the right from the picture (so that it do not cover any part of it)? Ideally the color bar should show the whole continuous spectrum of colors and a few values corresponding to the colors (at least the extreme ones)?
  Do you happen to know how to achieve this?</p>
  
  <p>Thank you for your help!</p>