0

I am trying to use networkD3 to create a Sankey diagram and I have difficulties creating the preferred layers in the diagram.

I see that the famous example below has a wonder distinct layer, but cannot figure out how this can be produced. For example, how can we put the layer in the exact column of figure as we preferred?

Example of sankey diagram

This is the code for the example.

URL <- paste0('https://cdn.rawgit.com/christophergandrud/networkD3/',
              'master/JSONdata/energy.json')
energy <- jsonlite::fromJSON(URL)

# Plot
sankeyNetwork(Links = energy$links, Nodes = energy$nodes, Source = 'source',
              Target = 'target', Value = 'value', NodeID = 'name',
              units = 'TWh', fontSize = 12, nodeWidth = 30)

Thank you very much in advance.

user2554330
  • 37,248
  • 4
  • 43
  • 90
Jie SU
  • 1
  • 1
  • It's not clear what you want to do. Your code gives the example you showed; if you want something different, you should show code that doesn't work as well, and explain what is wrong with it. – user2554330 Jul 05 '23 at 11:24

0 Answers0