gganimate
graph plot#
Link to script in header
The plot is easily animated with gganimate
, using transition_time
to specify when each row should be animated, using shadow_mark
causes the edges to persist, so that the melody leaves a trail of edges through the graph.
melody_graph_plot +
transition_time(t) +
shadow_mark()
This was then rendered to an animation using animate
; I used the av_renderer
option so that it could be combined with audio.
animate(
melody_animation,
width = 1330,
height = 882,
renderer = av_renderer('outputs/av/animation.mp4'),
frame_time = t,
duration = 10.2
)
Unsolved problem#
It was here I encountered a big hurdle in the animation, however. Something about self-loops causes the next edge to drop from the animation, but the self loop at the start from D to D in the first row of the graph is required to get the timing correct. I tried creating a static plot and combining images, but still ran into persistent timing issues.