Questions tagged [sankey-diagram]

Sankey diagrams are a kind of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity. They are typically used to visualize energy or material or cost transfers between processes.

752 questions
5
votes
3 answers

How to prepare input data for a sankey diagrams in R?

I am trying to produce a sankey diagram in R, which is also referred as a river plot. I've seen this question Sankey Diagrams in R? where a broad variaty of packages producing sankey diagrams are listed. Since I have input data and know different…
Marcin
  • 7,834
  • 8
  • 52
  • 99
5
votes
1 answer

Own colour range for Sankey Diagram with networkD3 package in R

I am trying to plot Sankey diagrams using sankeyNetwork() in networkD3 package. sankeyNetwork(Links = Flow_data, Nodes = Nodes_data, Source = "Source_ID", Target = "Target", Value = "value", NodeID = "Nodes_name", width = 1000,…
AEdiger
  • 51
  • 1
  • 2
5
votes
1 answer

Sankey diagrams with crossing branches

I would like to script a partially circular Sankey diagram where some branches must cross the other ones. Something like this (EDIT: better example where branches of one diagram actually cross and reconnect): . I am familiar with matplotlib, but…
eudoxos
  • 18,545
  • 10
  • 61
  • 110
5
votes
1 answer

How to assign the x-axis position of a node in a Sankey Diagram (D3) from the json file

I finally found a Sankey Diagram in D3 that allows movement of the nodes across the x-axis, but I would like to assign a value from the json file to fix the position in particular places. http://bl.ocks.org/d3noob/raw/5028304/ What I am trying to…
Ernesto
  • 199
  • 2
  • 9
4
votes
0 answers

Negative values in Sankey diagram visualizing losses

US_TOTAL_REVENUE = 50 INTERNATIONAL_TOTAL_REVENUE = 50 REVENUE = 100 GROSS_PROFIT = 10 COST_OF_REVENUE = 110 We have a business that operates on a loss. Their COST_OF_REVENUE (110) is higher than their REVENUE (100) resulting in a GROSS_PROFIT /…
4
votes
2 answers

How to skip nodes with NA value in ggsankey?

Suppose I have this dataset (the actual dataset has 30+ columns and thousands of ids) df <- data.frame(id = 1:5, admission = c("Severe", "Mild", "Mild", "Moderate", "Severe"), d1 = c(NA, "Moderate", "Mild",…
4
votes
0 answers

Extract X and Y coordinates from Plotly Sankey diagram

Where does Plotly store the X and Y coordinates of nodes (or the Plotly equivalent of XY coordinates)? Specifically when type = "sankey". For instance: library(plotly) fig <- plot_ly( type = "sankey", orientation = "h", node = list( …
Obed
  • 403
  • 3
  • 12
4
votes
0 answers

Confluencing/Merging Flows in ggalluvial

I need to create a particular type of plot using ggalluvial. From the vignette of the package: require(ggalluvial) data(vaccinations) vaccinations <- transform(vaccinations, response = factor(response,…
userq8957289475
  • 297
  • 1
  • 11
4
votes
1 answer

plot a sankey diagram from timeserie dataframe

I have a dataframeA date Cluster count Users 01/01/2021 ClusterA 10 01/01/2021 ClusterB 10 01/01/2021 ClusterB 9 02/01/2021 ClusterA 14 02/01/2021 ClusterB 10 02/01/2021 ClusterB 5 i want to visualize the…
4
votes
0 answers

d3 version 3 sankey misaligning and the path is exceeded its source and target boundaries

the path is exceeding when we have huge data. getting this issue when the source and target have bigger shock width . is there a way when i can fix the path not to exceed the borders. thankyou my code var svg =…
Abid
  • 344
  • 1
  • 4
  • 21
4
votes
1 answer

How to add more space between title and Sankey Diagram?

I'm using python with plotly to create Sankey Diagram. this it the text for the title/subtitles & a picture of the problem (the title overlaps with the diagram). How can I create more space between the two? I've tried adding "height=#' to the layout…
carsof
  • 83
  • 1
  • 8
4
votes
1 answer

How can I save a networkD3::sankeyNetwork() into a static image automatically via rmarkdown?

When I write a report in rmarkdown, all my figures as save automatically under the folder graphs. However, as a Sankey diagram is different, it does not save as a picture (.png, etc...) automatically. Is there a workaround for this? (without…
4
votes
0 answers

Sankey plot has self loops due to identical labels in multiple columns

Consider a dataframe: animal animal2 size count dog dog small 2 dog cat large 3 cat dog small 1 dog pig large 5 cat cat large 3 pig dog small 9 pig cat large 2 cat pig large …
Qubix
  • 4,161
  • 7
  • 36
  • 73
4
votes
1 answer

Add node count to Plotly Sankey diagram

I would like to add node count to each node in a Plotly Sankey diagram (https://plot.ly/python/sankey-diagram/) to look like the count referenced by red arrows. Is this possible? I cannot find example of this in plotly. The example, I provided…
fcol
  • 169
  • 3
  • 15
4
votes
2 answers

How to show a legend in plotly (python) sankey?

I want to plot some sankey diagrams representing mass flows of different substances for a report. I want to put a legend to differentiate the substances but I don't know how to do it. I've tried showlegend without success import…
Nabla
  • 1,509
  • 3
  • 20
  • 35