Hi there,
I want to animate some simple graphs with changing colors in their edges. I thought it would be simple but I am definitely not a Julia expert and I am a bit stuck.
I tried animating just the color of a single edge, with the following code:
using Graphs
using GraphPlot
using Plots
using Random
# Graph
G = Graph(5);
add_edge!(G, 1, 2);
add_edge!(G, 2, 3);
add_edge!(G, 1, 3);
add_edge!(G, 1, 4);
add_edge!(G, 4, 5);
add_edge!(G, 1, 5);
# Node positions
X = [1.0,0.0,0.0,2.0,2.0]
Y = [0.5,0.0,1.0,0.0,1.0]
# Colormap and color per iteration
cmap = range(HSL(colorant"blue"), stop=HSL(colorant"yellow"), length=360)
colorlist = rand(100) * 360
anim = Animation()
for i ∈ 1:100
## Get edge color at this instant
color = cmap[Int(round(colorlist[i]))]
edgecolor=["#389826","#CB3C33","#9558B4","#2458B2","#9558B2", color]
plt = gplot(G, X,Y, nodelabel=1:5, NODESIZE=0.05, EDGELINEWIDTH=2, nodefillc=colorant"grey", edgestrokec=edgecolor)
frame(anim, plt)
end
gif(anim)
The error I get is MethodError: no method matching frame(::Animation, ::Compose.Context)
, which I am not sure how to interpret nor fix… Any help is appreciated, thanks.