sankey-diagram

Transition (Sankey) plot with time on x axis

故事扮演 提交于 2019-12-08 02:28:58
问题 I have a transition matrix as following: 1. A A B 2. B C A 3. A C C where each column represents periods,each row represents an agent and each letter represents a state. I would like a create a plot such as Sankey Diagram which shows transitions from states to states in each period. Agents' identities are not important. So I would like to have a plot like this: . It seems that I can use networkD3 or googleVis packages. However since the position of each node is endogenously determined by the

Strange symbol “” appearing from rChart sankey output in Shiny

倾然丶 夕夏残阳落幕 提交于 2019-12-07 19:32:34
问题 Here's a screenshot of the output: The problem seems to be with the $setLib() function. As depending on the directory given, it gives a corresponding string output. Providing the correct directory produces the symbol  . For example providing a URL produces this output without the chart: Code - sankeyPlot$setLib("https://github.com/timelyportfolio/rCharts_d3_sankey") Output - https://github.com/timelyportfolio/rCharts_d3_sankey/layouts/chart.html Here's a sample code to replicate the error:

Python Plotly Sankey Graph not showing up

爱⌒轻易说出口 提交于 2019-12-07 15:12:26
Was wondering if anyone can help figure out why this Sankey diagram is not working. I am pretty sure I followed the proper syntax and conventions to use the module. Been banging my head on the table because of this. import plotly.offline data_trace = {'domain': {'x': [0, 1], 'y': [0, 1]}, 'height': 772, 'link': {'label': ['EM', 'GWF9C51E', 'GWF9C511', 'GWF9C51E Sensor Set', 'GWF9C511 Sensor Set'], 'source': [0, 1, 3, 1, 4, 2, 0, 2], 'target': [1, 3, 1, 0, 2, 0, 2, 4], 'value': [40, 76, 29, 86, 30, 75, 41, 65]}, 'node': {'color': ['blue', 'yellow', 'yellow', 'green', 'green'], 'label': ['EM',

How to sort source and/or target nodes in a sankey diagram within a shiny app?

末鹿安然 提交于 2019-12-07 08:30:46
问题 I have a simple sankey diagram, generated using networkD3 package inside a shiny app. How can source and/or target nodes be sorted? As you can see in the MWE, by default, neither source nodes (A, B, C, D, E) nor target nodes (V, W, X, Y, Z) are sorted. At least, sorting is not comprehensible to me. Code: library("shiny") library("networkD3") ui <- fluidPage( column(3), column(6, sankeyNetworkOutput("mySankeyD")), column(3) ) server <- function(input, output) { output$mySankeyD <-

How to control node labels in Sankey diagram

元气小坏坏 提交于 2019-12-06 16:09:03
问题 I have a Sankey diagram I'm creating in R. It produces the diagram but the node names are placed on the left of the nodes for the right side nodes. I would like all names to be on the right so the real names (which are longer) don't overlap with each other. Below is a complete set of working code that will generate the diagram I am currently working with. library(networkD3) nodes <- data.frame('name' = c('Node0','Node1','Node2','Node3','Node4','Node5','Node6', 'Node7','Node8','Node9','Node10'

Vertical sort of nodes in D3 Sankey diagram

北战南征 提交于 2019-12-06 13:39:18
问题 I'm trying to achieve a basic sankey diagram building on top of this example: http://bl.ocks.org/d3noob/c9b90689c1438f57d649 By default they get sorted by value. I want to customize the vertical order of the nodes. Here is an example: In this case I'd like to always keep "A" on top. Any thoughts on how to do that? Similar question: D3 sankey diagram - enforce node position 回答1: You can modify this function: function center(node) { return node.y + node.dy / 2; } like this: function center(node

plot line width (size) based on counts using ggplot or any other method in R

最后都变了- 提交于 2019-12-06 11:19:15
I have a dataset in long-format, each ID 'walks' 3 steps, each step (variable name is step) can land on different locations (variable name is milestone), I want to draw all of the paths. Because there are some paths more traveled, I want to make the width (size) of the paths proportional to their counts. I am imagining it to be something like geom_line(aes(size=..count..)) in ggplot, but it doesn't work. Below is my code, in the code you can find the url for the example dataset. My silly solution to add width was to dodge the line, but it's not proportional, and it leaves cracks. ddnew <- read

Change Font Size on rCharts Sankey Diagram

一世执手 提交于 2019-12-06 09:21:49
I'm using the following code to create a Sankey Diagram using rCharts. I wish to increase the font size of the text printed on the Sankey Diagram. I can't find a manual to show me how to do this. Thoughts? rm(list = ls()) require(reshape) require(rCharts) require(rjson) target <- c('TMF', 'TMF', 'TMF','Evaporation','Mill Reclaim','Void Losses','Seepage') source <- c('Precipitation & Run Off','Slurry','Other','TMF','TMF','TMF','TMF') value <- c(638,1610,755,118,1430,466,2) x <- data.frame(target,source,value) sankeyPlot <- rCharts$new() sankeyPlot$set( data = x, nodeWidth = 10, nodePadding = 10

Strange symbol “” appearing from rChart sankey output in Shiny

一曲冷凌霜 提交于 2019-12-06 08:10:48
Here's a screenshot of the output: The problem seems to be with the $setLib() function. As depending on the directory given, it gives a corresponding string output. Providing the correct directory produces the symbol  . For example providing a URL produces this output without the chart: Code - sankeyPlot$setLib("https://github.com/timelyportfolio/rCharts_d3_sankey") Output - https://github.com/timelyportfolio/rCharts_d3_sankey/layouts/chart.html Here's a sample code to replicate the error: require(rCharts) require(rjson) require(shiny) links <- matrix(unlist( rjson::fromJSON( file = "http:/

Connecting flows in matplotlib sankey diagram

╄→尐↘猪︶ㄣ 提交于 2019-12-06 06:00:43
问题 I am using matplotlibs sankey functionality and have a problem with connecting two flows. Basically, I just want to connect the flow Qab,rekup to the end of the flow Qzu,rekup (see Screenshot). Seems to be quite easy but I still haven't figured out how to manage this. Here's the screenshot: https://www.dropbox.com/s/2satz9ryniy958v/Sankey.png?dl=0 Here's the code: import numpy as np import matplotlib.pyplot as plt from matplotlib.sankey import Sankey fig = plt.figure() ax = fig.add_subplot(1,