sankey-diagram

How to align text vertically on a node within a Sankey diagram (D3.JS)?

只谈情不闲聊 提交于 2019-12-06 04:47:10
问题 I have modified Mike Bostok example of a Sankey diagram in D3.Js from http://bost.ocks.org/mike/sankey/ to display the value of each node as this: Sankey http://uweb.cs.uvic.ca/~maleh2/sankey.png node.append("text") .attr("class","nodeValue"); ///align vertically?? node.selectAll("text.nodeValue") .attr("x", sankey.nodeWidth() / 2) .attr("y", function (d) { return (d.dy / 2) }) .text(function (d) { return formatNumber(d.value); }) .attr("text-anchor", "middle"); //.attr("transform", "rotate(

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

你说的曾经没有我的故事 提交于 2019-12-05 18:05:34
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 <- renderSankeyNetwork({ myDf <- list( nodes=data.frame(name=c( "A", "B", "C", "D", "E", "V", "W", "X", "Y", "Z")),

Adjusting sankey plot in tabbed section

£可爱£侵袭症+ 提交于 2019-12-05 15:44:39
问题 In the r-markdown document given below, I use tabbed sections to display sankey plots. However, when a sankey plot is in a tab other than the first, adjusting (using htmlwidgets::onRender function) does not work. Does anybody know a way to overcome that problem? Related question: How to control node labels in Sankey diagram --- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(networkD3) library(htmlwidgets) nodes <- data.frame

Problems while reproducing Sankey chart example with d3_sankey

寵の児 提交于 2019-12-05 03:28:53
I am trying to reproduce simple example with rCharts library to plot sankey chart. I found this example from scratch and tried to reproduce it, however, I came up with some problems. Firstly I have tried running this code without nothing. Then I found out and realized, that I need d3_sankey in my computer. So, I have downloaded it from here and copied to C:\Users\adomas\Documents\R\win-library\3.0\rCharts\libraries\widgets\d3_sankey . Then I've tried that unchanged code once more and still got the following error: Error in file(con, "r") : cannot open the connection In addition: Warning

Creating a Sankey Diagram using NetworkD3 package in R

冷暖自知 提交于 2019-12-05 01:22:28
问题 Currently I am trying to create an interactive Sankey with the networkD3 Package following the instructions by Chris Grandrud (https://christophergandrud.github.io/networkD3/). What I don't understand is is table-format, since he just uses two columns for visualising more transitions. To be more specific, I have a dataset containing four columns which represent 4 years. Inside these columns are different hotel names, whereas each row represents one customer, who is "tracked" over these four

Modify networkD3 sankey plot with user-defined colors

点点圈 提交于 2019-12-04 13:27:55
问题 I have a sankey plot created in networkD3 package. I would like to modify the colors and transparency of both nodes and links. My data networkD3_data is appended at the end. Question 1: How to modify node colors with user-defined palette? I am not sure how to modify the colors with user-defined palette. It is necessary for me to use the same color palette specific to each node source to keep consistent with other plots I have. Currently I am able to have each source node be a different color

Connecting flows in matplotlib sankey diagram

南楼画角 提交于 2019-12-04 09:04:30
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, 1, 1, xticks=[], yticks=[], title="Vereinfachtes Kraftwerksmodell") sankey = Sankey(ax=ax, unit=None)

Put line break in node labels in networkD3 sankey diagram

故事扮演 提交于 2019-12-04 02:34:34
++++++++++++++++ Update: I think the answer to my question is that you can't put line breaks in. A colleague pointed out to me the node labels are SVG blocks, which don't support line breaks. ++++++++++++++++ How do I put a line break into the node labels for a sankey diagram produced using the networkD3 R package? Borrowing the example from Place text values to right of sankey diagram I can add values to the lables: library(networkD3) library(data.table) set.seed(1999) links <- data.table( src = rep(0:4, times=c(1,1,2,3,5)), target = sample(1:11, 12, TRUE), value = sample(100, 12) )[src <

Adjusting sankey plot in tabbed section

最后都变了- 提交于 2019-12-04 01:43:42
In the r-markdown document given below, I use tabbed sections to display sankey plots. However, when a sankey plot is in a tab other than the first, adjusting (using htmlwidgets::onRender function) does not work. Does anybody know a way to overcome that problem? Related question: How to control node labels in Sankey diagram --- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(networkD3) library(htmlwidgets) nodes <- data.frame('name' = c('Node0','Node1','Node2','Node3','Node4','Node5','Node6', 'Node7','Node8','Node9','Node10',

How to make a googleVis multiple Sankey from a data.frame?

走远了吗. 提交于 2019-12-03 16:52:02
Aim I am aiming to make a multiple Sankey in R using the googleVis package. The output should look similar to this: Data I've created some dummy data in R: set.seed(1) source <- sample(c("North","South","East","West"),100,replace=T) mid <- sample(c("North ","South ","East ","West "),100,replace=T) destination <- sample(c("North","South","East","West"),100,replace=T) # N.B. It is important to have a space after the second set of destinations to avoid a cycle dummy <- rep(1,100) # For aggregation dat <- data.frame(source,mid,destination,dummy) aggdat <- aggregate(dummy~source+mid+destination,dat