Vertex animation

Let’s say that we want to display a number of different vertex layouts as an animated sequence. Simply specify a list of layouts in the layout parameter instead of a single layout. For instance (you can interact with the plot during the animation):

library(threejs)
data(LeMis)
graphjs(LeMis,
        layout=list(layout_randomly(LeMis, dim=3),
                    layout_on_sphere(LeMis),
                    layout_with_drl(LeMis, dim=3),
                    layout_with_fr(LeMis, dim=3)),
        main=list("random layout", "sphere layout",
                  "drl layout", "fr layout"),
        fpl=300)

Note that we also supplied a list of main title text, one title corresponding to each layout. The fpl=300 parameter the (linear) interpolating steps between each layout to 300 in this example.

Notes

The following graphjs() function parameters may be supplied as lists for animation:

  • graph object
  • layout
  • vertex.color
  • edge.color
  • main (title text)

Similarly to igraph, options like vertex color and edge color can alternatively be defined within the graph objects. If both styles of specification are used, the explicit function parameter version takes precedence.

Limitations

Each layout must include the same number of vertices. This limitation is imposed for performance reasons. Althoug the number of vertices must remain constant during the animation, their color and transparency values may be changed dynamically as shown in the next example below.


Click here to proceed to an animation example with different colors.