简体   繁体   English

如何制作一个 plot 代表与 python matplotlib 的连接关系?

[英]How can I make a plot representing connection relationship with python matplotlib?

I want to make a plot like this with python, I searched in matplotlib Gallery but can't find any similar one:我想用 python 制作一个像这样的 plot,我在 matplotlib Gallery 中搜索但找不到任何类似的: 在此处输入图像描述

The plot is made based on 2D matrix. plot 是基于二维矩阵制作的。 For example, I have a 5*5 matrix, symmetric about the diagonal:例如,我有一个 5*5 的矩阵,关于对角线对称:

Connection = np.array([0,0,1,1,1],
                      [0,0,1,0,1],
                      [1,1,0,1,0],
                      [1,0,1,0,0],
                      [1,1,0,0,0]) 

The element represent the connections relationships, if Connection[ i ][ j ] = 0 , means no connections between dot i and dot j .该元素表示连接关系,如果Connection[ i ][ j ] = 0 ,则表示dot i and dot j之间没有连接。 If Connection[ i ][ j ] = 1 , then there should be a connection line between dot i and j如果Connection[ i ][ j ] = 1 ,那么dot i and j之间应该有一条连接线

Since it's a bidirectional relation and the matrix is symmetric, if dot 1 has connection with dot 3, then dot 3 should also has connection with dot 1.由于它是双向关系且矩阵是对称的,如果点 1 与点 3 有联系,那么点 3 也应该与点 1 有联系。

For the matrix given, the expected plot should looks like(I made this by powerpoint):对于给定的矩阵,预期的 plot 应该看起来像(我通过 powerpoint 制作的): 在此处输入图像描述

How can I make this kind plots?我怎样才能制作这种情节? Thanks in advance!提前致谢!

It can be solved by networkx package可以通过networkx package解决

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用表示matplotlib中原始数据的颜色条绘制对数标准化的imshow图 - How can I draw a log-normalized imshow plot with a colorbar representing the raw data in matplotlib 如何获得轮廓 plot 和 3D plot 使用 z1587383CF8C21507D06FB 的 zDDDA 和 a set5ZEF3 列的起始点来表示? - How can I obtain a contour plot and a 3D plot using Matplotlib starting from a set of 3 columns representing x,y and z points? 我可以在 python 中用 matplotlib 的字符串标签制作散点 plot 吗? - Can i make a scatter plot with string labels by matplotlib in python? 如何制作 C++ 数组的动画颜色图? 导出到 Python 并使用 \\matplotlib? - How can I make animated colormap plot of C++ arrays? Export to Python and use \matplotlib? python 2.7 matplotlib pylab:我的情节是空的。 如何使数据点显示在图中? - python 2.7 matplotlib pylab : My plot is empty. How can I make the data points show up in the plot? 如何使密集的 plot 上的所有点在 matplotlib 中可见? - How can I make all the points on a dense plot visible in matplotlib? 如何在 matplotlib 中制作按密度着色的散点图? - How can I make a scatter plot colored by density in matplotlib? 如何让 matplotlib 忘记删除的 plot 元素? - How can I make matplotlib forget about removed plot elements? 我该如何在matplotlib中制作类似信号图的图? - How can I make a signum-like plot in matplotlib? 如何在 Google Colab 交互式中制作 matplotlib 图 - How can I make a matplotlib plot in Google Colab interactive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM