Hi
I’m taking first steps with Makie, trying to produce an animated network graph. There are three nodes and I want the edge width, arrow size and node size to vary according to supplied matrices. The static graph works with observables, but attempts to animate give error messages:
- ERROR: KeyError: key: node_size not found (if I uncomment the first commented line in the record command)
- ERROR: KeyError: key: arrow_shift not found (if I uncomment the second commented line in the record command).
Grateful for any help. MWE below:
using GraphMakie
using Graphs
using GraphMakie.NetworkLayout
using Random
Random.seed!(12345)
n = 10
lw = rand(n,6).*10 #line width
as = 5*lw # arrow size - this scaling gets a reasonable result
ns = rand(n,3).*100 # node size (radius pixels, so square root would make marker area map to size)
g = SimpleDiGraph(3); add_edge!(g, 1, 2); add_edge!(g, 1, 3); add_edge!(g, 2, 1); add_edge!(g, 2, 3); add_edge!(g, 3, 1); add_edge!(g, 3, 2);
# works ok
f, ax, p = graphplot(g; curve_distance=-.2, node_size=ns[1,:], edge_width = lw[1,:], arrow_size = as[1,:])
# Now using observables
olw = Observable(lw[1,:])
oas = Observable(as[1,:])
ons = Observable(ns[1,:])
# works ok
f, ax, p = graphplot(g; curve_distance=-.2, node_size=ons, edge_width = olw, arrow_size = oas)
rows = 2:n
#works ok but not if I uncomment commented lines
record(f, "t_animation.mp4", rows; framerate = 2) do frame
olw[] = lw[frame,:]
# ons[] = ns[frame,:]
# oas[] = as[frame,:]
end