Mathematica GraphPlot 和 EdgeRenderingFunction

发布于 2024-09-25 02:36:46 字数 585 浏览 3 评论 0原文

当我等待 排序时 最后,我想调整我正在处理的 Mathematica 图表的一部分。问题是节点位于边缘之上,我想知道是否有办法扭转这种情况。在图像中,您可以看到箭头未正确显示...

我正在使用自定义 VertexRenderingFunctionEdgeRenderingFunction 参数执行 GraphPlot[] 。它看起来像这样:

箭头在哪里?你能看到他们吗?你拿走了我的箭吗? http://img816.imageshack.us/img816/9703/graphbadarrows.png

如您所见,如果箭头位于节点顶部,那就。有没有一种简单的方法可以欺骗它?

While I'm waiting for the sorting to finish, I would like to adjust a part of Mathematica graph I'm working on. The problem is that nodes are on top of edges, I wonder if there is a way to reverse that. In the image you can see that arrows are not showing proper...

I'm doing a GraphPlot[] with custom VertexRenderingFunction and EdgeRenderingFunction paramaters. It looks something like this:

Where are the arrows? Can you see them? Did you take my arrows? http://img816.imageshack.us/img816/9703/graphbadarrows.png

As you can see, it would be as they say cool if the arrows were on top of the nodes. Is there an easy way to hax it in?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

银河中√捞星星 2024-10-02 02:36:46

我不知道是否有办法直接使用 GraphPlot 选项来执行此操作,但您可以直接操作 GraphPlot 生成的 Graphics 对象。例如,这是一个与您的特征相似的图表。

bg = GraphPlot[Table[i -> Mod[3 i + 1, 9],
  {i, 0, 8}], DirectedEdges -> True,
  VertexRenderingFunction -> (
  {{White, Disk[#, 0.15]}, Circle[#, 0.15]} &),
  EdgeRenderingFunction -> (Arrow[#1] &)]

您可以检查 Graphics 基元和指令的结构,如下所示:

  bg // InputForm

您可以看到箭头放置在顶点之前。只需按如下方式反转即可。

  MapAt[Reverse, bg, {1, 1}]

当然,您的 Graphics 对象可能具有不同的结构。

马克·麦克卢尔

I don't know if there is a way to do this directly with GraphPlot options or not but you could manipulate the Graphics object produced by GraphPlot directly. For example, here's a graph whose features are similar to yours.

bg = GraphPlot[Table[i -> Mod[3 i + 1, 9],
  {i, 0, 8}], DirectedEdges -> True,
  VertexRenderingFunction -> (
  {{White, Disk[#, 0.15]}, Circle[#, 0.15]} &),
  EdgeRenderingFunction -> (Arrow[#1] &)]

You can examine the structure of the Graphics primitives and directives as follows:

  bg // InputForm

You can see that the arrows are placed down before the vertices. Simply reverse this as follows.

  MapAt[Reverse, bg, {1, 1}]

Of course, your Graphics object will likely have a different structure.

Mark McClure

拥抱没勇气 2024-10-02 02:36:46

马克的答案完全符合您的要求——您可以编写自己的函数来自动执行反向操作。

一个不太直接的解决方案可能是将箭头从末端向后拉一点:

GraphPlot[Table[i -> Mod[3 i + 1, 9], {i, 0, 8}], 
 VertexRenderingFunction -> ({{White, Disk[#, 0.15]}, 
     Circle[#, 0.15]} &), DirectedEdges -> True, 
 EdgeRenderingFunction -> ({Arrowheads[{{.05, .8}}], Red, 
     Arrow[#]} &)]

这也将减少节点处的拥塞。

Mark's answer does exactly what you asked for -- and you could write your own function that automates the Reverse.

A less direct solution might be to just draw the arrow heads back from the end a little:

GraphPlot[Table[i -> Mod[3 i + 1, 9], {i, 0, 8}], 
 VertexRenderingFunction -> ({{White, Disk[#, 0.15]}, 
     Circle[#, 0.15]} &), DirectedEdges -> True, 
 EdgeRenderingFunction -> ({Arrowheads[{{.05, .8}}], Red, 
     Arrow[#]} &)]

This would also reduce the congestion at the nodes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文