Home > Enterprise >  how to make sankyplots with no color for source and target node and how to do legend to show the dif
how to make sankyplots with no color for source and target node and how to do legend to show the dif

Time:01-31

I am working on network data and want to visualize it using sankeyNetwork() from the enter image description here


networkD3 does not have any built-in legend creation options, however, if you want to make a legend yourself, you'll probably want to use a consistent set of colors so that you can use them with whatever you use to make a legend. You can do that like this...

colourScale <- 
  'd3.scaleOrdinal()
     .domain(["A", "B", "C", "D"])
     .range(["red", "blue", "green", "yellow"])'

sankeyNetwork(Links = data,
              Nodes = nodes,
              Source = "IDsource",
              Target = "IDtarget",
              Value = "value",
              NodeID = "name", 
              sinksRight=FALSE,
              nodeWidth=40,
              fontSize=13,
              nodePadding=20,
              LinkGroup = 'group',
              NodeGroup = NULL,
              colourScale = colourScale)

enter image description here

  •  Tags:  
  • Related