gpt4 book ai didi

graph - 在 Wolfram Mathematica 中为图形上的边着色

转载 作者:行者123 更新时间:2023-12-01 23:34:09 25 4
gpt4 key购买 nike

是否可以使用颜色函数在 Wolfram Mathematica 中为图形的边着色,这取决于边上的坐标?就像在 Plot[] 中使用 ColorFunction 选项一样。

我在图的边缘指定了一个函数,具体取决于边缘的坐标。
是否可以在边缘绘制此函数的密度?
感谢您的回复。

PS:第一个想法——在EdgeRenderingFunction中使用Inset[]来插入图形化的彩色对象,但是看起来很不自然。有什么简单的方法吗?

最佳答案

一种使用方式 ColorFunction为图形中的边缘着色是:

  ClearAll[colorededge];
colorededge[pts_, colorfunc_: Function[{x, y}, ColorData["TemperatureMap"][y]]] :=
ListPlot[pts, Joined -> True, PlotStyle -> Thick, Axes -> False,
ColorFunction -> colorfunc, ColorFunctionScaling -> True];
edgshpfnc = (If[Last[#2] == "B", First@colorededge[#1],
First@colorededge[#1, Function[{x, y}, Blend[{Yellow, Red}, x]]]] &);
Graph[{"A" -> "B", "B" -> "C", "C" -> "A"},
VertexCoordinates -> {"A" -> {0, 0}, "B" -> {1, 1}, "C" -> {2, 0}},
EdgeShapeFunction -> edgshpfnc, VertexLabels -> "Name", ImagePadding -> 10]



enter image description here


 GraphPlot[{"A" -> "B", "B" -> "C", "C" -> "A"},
EdgeRenderingFunction -> edgshpfnc, VertexLabeling -> True]



enter image description here

关于graph - 在 Wolfram Mathematica 中为图形上的边着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10592357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com