title: How to make edge colours a gradient in ggnet2 in R?
body: <p>I'm trying to produce a plot using the <code>ggnet2</code> package in <code>R</code>. I have created a network (<code>net.bg</code>)</p>
  
  <pre class="lang-r prettyprint-override"><code>library(igraph)
  library(GGally)
  library(network)
  
      direction &lt;- c(2,1,3,1,4,1,5,1,3,2,4,2,5,2,4,3,5,3,5,4)
      gr &lt;- matrix(direction, nrow = 2)
      x1 &lt;- 10.59
      x2 &lt;- 15.74
      x3 &lt;- 0
      x4 &lt;- 100
      x5 &lt;- 28.63
  
      RImp &lt;- data.frame(x1,x2,x3,x4,x5)
      nam &lt;- names(RImp)
      RImp &lt;- as.numeric(RImp)
      Rint &lt;- c(2.96, 1.34, 1.27, 1.1, 2.22, 1.24, 3.11,
                2.52, 0.96, 1.08)
  
      net.bg &lt;- make_graph(gr, 5)
  </code></pre>
  
  <p>and I am using <code>ggnet2</code> to plot it like so:</p>
  
  <pre class="lang-r prettyprint-override"><code>
  library(GGally)
  library(igraph)
  
      p   &lt;- ggnet2(net.bg, 
                    mode = "circle", 
                    size = RImp,
                    color = RImp,
                    node.color = "grey50",
                    label = nam,
                    edge.size = Rint, 
                    edge.label = Rint,
                    edge.color = "grey") 
       p
  </code></pre>
  
  <p>Where, <code>RImp</code> is is a set of values that determines the node size, <code>Rint</code> determines the edge size, and <code>nam</code> is just the name of the nodes.</p>
  
  <p>This produces a plot like the one below:</p>
  
  <p><a href="https://i.stack.imgur.com/APR78.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/APR78.png" alt="Network style plot"></a></p>
  
  <p>However, what I am trying to achieve is to make the edge colour a gradient from low to high values. I was trying something like this:</p>
  
  <pre class="lang-r prettyprint-override"><code>    colfunc &lt;- colorRampPalette(c("black", "red"))
      p   &lt;- ggnet2(net.bg, 
                    mode = "circle", 
                    size = RImp,
                    color = RImp,
                    node.color = "grey50",
                    label = nam,
                    edge.size = Rint, 
                    edge.label = Rint,
                    edge.color = colfunc(length(Rint))) 
       p
  
  </code></pre>
  
  <p>This colours the edges in the gradient... however, it is not colouring them from low to high values... It is colouring them in the path direction.</p>
  
  <p>Any suggestions as to how I would colours the edges in a gradient from low to high values?</p>