Coloring edges on graph in Wolfram Mathematica
Is it possible to color an edge of graph in Wolfram Mathematica using color function, that depends on coordinate on the edge? Like using ColorFunction option in Plot[].
I have a function specified on the edge of the graph, depending on coordinate at the edge. Is it possible to paint a dencity of this function on the edge? Thanks for responce.
PS: The first idea - to use Inset[] to plug in graphical colored object in EdgeRenderingFunction, but it seems to be quite unnatural. Is there any simpliar ways?
One way to use ColorFunction
to color edges in a Graph is:
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]
gives
and
GraphPlot[{"A" -> "B", "B" -> "C", "C" -> "A"},
EdgeRenderingFunction -> edgshpfnc, VertexLabeling -> True]
gives
链接地址: http://www.djcxy.com/p/20258.html上一篇: 反射/反转单向图形边缘