Search code examples
rnetworkd3

R networkD3 package: edge coloring in simpleNetwork()


Is there a way to colour the edges of the network using the package networkD3 in R? All I have seen is ways of colouring the nodes but I have not seen anything regarding colouring the edges? Thanks


Solution

  • see the help file with ?simpleNetwork

    it describes all the possible arguments, including...

    linkColour - character string specifying the colour you want the link lines to be. Multiple formats supported (e.g. hexadecimal).

    library(networkD3)
    
    Source <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
    Target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
    NetworkData <- data.frame(Source, Target)
    
    simpleNetwork(NetworkData, linkColour = "green")
    

    enter image description here