I'm trying to produce a plot using the ggnet2
package in R
. I have created a network (net.bg) and I am using ggnet2
to plot it like so:
p <- ggnet2(net.bg,
mode = "circle",
size = RImp,
color = RImp,
node.color = "grey50",
label = nam,
edge.size = Rint,
edge.label = Rint,
edge.color = "grey")
p
Where, RImp is is a set of values that determines the node size, Rint determines the edge size, and nam is just the name of the nodes.
This produces a plot like the one below:
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:
colfunc <- colorRampPalette(c("black", "red"))
p <- 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
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.
Any suggestions as to how I would colours the edges in a gradient from low to high values?