我试着把一个二部集问题的连接矩阵形象化。我该如何做到最好呢?在
我从一个图形程序yed开始:
圆圈描述了红色和蓝色以及正方形之间的某种联系。红色和蓝色方块上都会有一些文字。在
不过,用matplotlib生成这个grafic会更好,因为我想在动态中生成附加的数据。我该怎么做呢? 我的数据看起来像这样:
数据:
name_blue name_red Connection Type
bluepart1 redpart1 1
bluepart1 redpart2 1
bluepart1 redpart3 1
bluepart3 redpart2 2
bluepart4 redpart2 2
...
等等。我想把姓名标签写在蓝色/红色方块上,这样用户就知道哪个是哪个。在
后续问题: 如何从中生成节点部分标记为蓝色/红色的图形?有点像这样:
但是节点反映了它们的二分性。在这方面我还是有点不清楚,主要是因为我不知道如何使用matplotlib来处理这个问题。我希望有一些关于如何可视化的好的建议,也许还有一个示例实现,为我指明方向。在
尝试使用networkx。您可以使用它在节点和链接上显示特定颜色的图形,以匹配您的数据。在
下面是一个例子:
用这样的彩色边来进行二部表示怎么样?在
下面是生成图像的代码。在
去弄点你在耶德画的东西
^{pr2}$这是NetworkX/Matplotlib的另一个想法
相关问题 更多 >
编程相关推荐