- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 python 中的 networks.draw() 函数绘制图形。尽管它不是有向图,但我具有按拓扑排序顺序排列的图的边。我想打印看起来像依赖 DAG 的图形以获得更好的可见性。目标是这样的:
我应该怎么做?
最佳答案
使用如下示例边列表,并构建无向图:
edges = [[1,3], [1,4], [1,5], [5,7], [5,8] ,[5,9],
[9,11], [9,12], [9,13], [2,4], [6,8] ,[10,12]]
G = nx.Graph()
G.add_edges_from(edges)
我们可以使用节点名称来定义一个字典,将节点名称映射到一条线,其中 x
坐标与节点名称相同。现在获得具有弯曲边缘的精美布局是棘手的部分。虽然这是必要的,否则边缘会相互重叠。这可以使用 matplotlib.axes.Axes.annotate
来完成.
请注意,我假设源在 even 节点号处的边有一个 正 符号弧,否则为负,如果不是这种情况,它应该是足够简单以适应:
pos = {node:(node,0) for node in G.nodes()}
plt.figure(figsize=(15,5))
ax = plt.gca()
for edge in edges:
source, target = edge
rad = 0.8
rad = rad if source%2 else -rad
ax.annotate("",
xy=pos[source],
xytext=pos[target],
arrowprops=dict(arrowstyle="-", color="black",
connectionstyle=f"arc3,rad={rad}",
alpha=0.6,
linewidth=1.5))
nx.draw_networkx_nodes(G, pos=pos, node_size=500, node_color='black')
nx.draw_networkx_labels(G, pos=pos, font_color='white')
plt.box(False)
plt.show()
关于python - 绘制具有弯曲边的拓扑有序图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62287492/
我正在使用我的简单 PHP 验证码算法 ( http://www.source.ofitall.com/devel/captcha.php ),我一直在努力尝试调整它以使其更具吸引力和更易于阅读,谷歌
我正在 android 中实现一个 ListView ,它看起来就像这样并滚动 我一直在通过在我的适配器的 getView 中设置膨胀行的布局参数来做到这一点,但由此引发的问题是 ListView 变
我正在尝试使用 flex 和 bison 创建一个计算器,它可以进行一组操作(结果分配给变量)。计算器使用存储器来存储这些变量。当我通过终端(标准输入键盘)进行此计算时,一切正常。但是,当我尝试使用文
我的Flex应用程序中有数据网格,我使用Arraycollection绑定(bind)数据网格(使用remoteobject方法调用从java类获取数据)。现在我正在数据网格中执行添加/编辑/删除,我
是否可以制作弯曲或拱形形状的矩形。这是我的 jsfiddle https://jsfiddle.net/dibyendu/y8pthz2x/ 。我想使用 d3 使雷达图轴上的这些矩形成为弧形/曲线 最
我有一张代表某个区域海拔的图像。但是制造它的无人机不一定走直线(尽管图像总是矩形的)。我还有每 20 厘米生成的 gps 坐标。 如何“弯曲”这个矩形图像(曲线/马赛克),使其代表无人机实际经过的弯曲
我经历了How to curve the top of a UIView Controller in Swift 并发表看法。它附在下面。我想从我的 View 中删除该背景色。我在 Storyboar
任何人都可以帮助弯曲 View 以达到以下效果。我正在使用自定义 View 组,我想操纵 Canvas 来实现以下效果,谁能帮帮我。 谢谢 最佳答案 你需要知道: Camera Matrix 这是一个
我尝试绘制一些 3D 正方形(在 iPhone 上使用 OpenGL)并让它们旋转,现在它们看起来像一个球体。 http://i618.photobucket.com/albums/tt265/Loy
我想创建一个 div,它是一个按钮,它包含一个国旗的图片和一个国家的 abv,我已经将一些代码放入我想要的内容中,但这不是 Bootstrap 的方式,我'我正在努力解决这个问题,以及如何使用 boo
现在我正在用一系列 View 填充 UIScrollView。需要扭曲 View 以使 UIScrollView 看起来像旋转木马。换句话说,当用户滚动时,它需要像一个圆圈。我以前从未做过类似的事情,
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我是一名优秀的程序员,十分优秀!