相关疑难解决方法(0)

如何使用数据框定义sankey图的结构?

这听起来像是一个非常广泛的问题,但是如果您让我描述一些细节,我可以向您保证这是非常具体的。以及令人沮丧,沮丧和愤怒。


下图描述了苏格兰选举,并基于plot.ly的代码:

情节1:

在此处输入图片说明

资料集1:

data = [['Source','Target','Value','Color','Node, Label','Link Color'],
        [0,5,20,'#F27420','Remain+No – 28','rgba(253, 227, 212, 0.5)'],
        [0,6,3,'#4994CE','Leave+No – 16','rgba(242, 116, 32, 1)'],
        [0,7,5,'#FABC13','Remain+Yes – 21','rgba(253, 227, 212, 0.5)'],
        [1,5,14,'#7FC241','Leave+Yes – 14','rgba(219, 233, 246, 0.5)'],
        [1,6,1,'#D3D3D3','Didn’t vote in at least one referendum – 21','rgba(73, 148, 206, 1)'],
        [1,7,1,'#8A5988','46 – No','rgba(219, 233, 246,0.5)'],
        [2,5,3,'#449E9E','39 – Yes','rgba(250, 188, 19, 1)'],
        [2,6,17,'#D3D3D3','14 – Don’t know / would not vote','rgba(250, 188, 19, 0.5)'],
        [2,7,2,'','','rgba(250, 188, 19, 0.5)'],
        [3,5,3,'','','rgba(127, 194, 65, 1)'],
        [3,6,9,'','','rgba(127, …
Run Code Online (Sandbox Code Playgroud)

python sankey-diagram jupyter-notebook plotly-python

8
推荐指数
1
解决办法
1535
查看次数

Plotly:如何从数据框中绘制桑基图?

我有一个数据框:

Vendor Name                 Category                    Count
AKJ Education               Books                       846888
AKJ Education               Computers & Tablets         1045
Amazon                      Books                       1294423
Amazon                      Computers & Tablets         42165
Amazon                      Other                       415
Flipkart                    Books                       1023
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用上述数据框绘制桑基图,源为Vendor Name,目标为Category,流或宽度为Count。我尝试使用 Plotly,但没有成功。有没有人有使用 Plotly 制作桑基图的解决方案?

谢谢

python pandas plotly sankey-diagram

5
推荐指数
1
解决办法
9389
查看次数