我试图创建一个sankey图,在R中使用了固定的节点和边缘颜色。这些颜色在.csv文件中以单独的颜色表示。
library(riverplot)
# import data
edges = read.csv("sankey_data_edges.csv")
nodes = read.csv("sankey_data_nodes.csv")
r <- makeRiver(nodes, edges)
plot( r )
sankey_data_nodes.csv包含:
ID x labels y col
1 1 G1 2 gr
我正在使用巧妙的方式创建一个sankey图,并且有一个内置的方法来使用'group‘来组合节点。但是,当我使用它时,这个节点的颜色将是黑色的,没有标签显示。这是预期的,因为分组节点的颜色可能会有所不同。但是,我不知道如何设置这个组的颜色。标签也是如此。有什么方法来定义这个吗?
示例代码:
import plotly.graph_objs as go
from plotly.offline import plot
value = [3,5,2,4,6]
source = [0,0,1,0,3]
target = [1,4,2,3,4]
color = ["blue",&
sankey图有节点限制吗?我正在尝试创建一个包含大量节点的图,但以下代码无法生成图(但没有给出错误警告)。
知道这里发生了什么吗?
# sankey chart using d3 plugin for rCharts and the igraph library
require(rCharts)
require(igraph)
# these are our vertices/nodes/end points/stages/categories/classes/whatever
nodes = c(1:36)
# the chart is basically a graph
pair
我可以使用基R的一部分Kyphosis数据集使用Rpart创建一棵树:
fit <- rpart(Kyphosis ~ Age + Number + Start,
method="class", data=kyphosis)
printcp(fit)
plot(fit, uniform=TRUE,main="Classification Tree for Kyphosis")
text(fit, use.n=TRUE, all=TRUE, cex=.8)
这就是这棵树的样子:
现在,为了更好地可视化树,我想使用一个使用巧妙的sank
我试图用rCharts库复制简单的示例来绘制sankey图表。我找到了并试图复制它,但是我想出了一些问题。
首先,我已经尝试了运行这个代码,没有任何东西。然后我发现并意识到,我需要d3_sankey在我的电脑。所以,我从下载并复制到C:\Users\adomas\Documents\R\win-library\3.0\rCharts\libraries\widgets\d3_sankey。
然后,我再次尝试了未修改的代码,但仍然得到了以下错误:
Error in file(con, "r") : cannot open the connection In addition: W