Stereonet animations in APSG

plane, line, vector, pole, arrow, fault and hoeppner methods of StereoNet can store created artists internally when keyword argument animate=True is passed and could be used for animation. Note that matplotlib rc parameter animation.html should be set to html5 for inline animations in Jupyter notebooks.

In [1]:
%pylab inline
from IPython.display import HTML
Populating the interactive namespace from numpy and matplotlib
In [2]:
from apsg import *
settings['figsize'] = (10, 8)

Firstly we create Group of planes to be animated.

In [3]:
g = G('90 45 270 45 0 45 180 45 45 90 135 90', Fol)

Than we simply sequentially plot, using one of the above mention methods, individual steps of animation. Note that animated objects are plotted with animate=True keyword argument. Finally we call animate method which returns matplotlib.animation.ArtistAnimation object.

In [5]:
s = StereoNet()
s.plane(g)
for t in arange(0, 360, 2):
    s.plane(g.rotate(Lin(90, 0), t), color='r', animate=True)

# s.animate(interval=40).save('animation.gif', writer='imagemagick', fps=30)
anim = s.animate(interval=40)
s.close()

Now to create an interactive JavaScript widget using the to_jshtml method:

In [6]:
HTML(anim.to_jshtml())
Out[6]: