Note
Go to the end to download the full example code.
Animated plots¶
run this example as a notebook — or grab the .ipynb (also linked at the bottom of the page)
Timeseries can be animated by passing animate=True to hyp.plot: each
trajectory is drawn progressively while the camera rotates around the
scene. The data here are two group-average brain-activity trajectories
(hyp.load('weights_avg')). The first animation uses the default (PCA)
reduction; the second reduces the same data with multidimensional scaling
instead, which changes the shape of the path the trajectories trace out.
# Code source: Andrew Heusser
# License: MIT
import hypertools as hyp
# load example data: two trajectories, each (timepoints, features)
data = hyp.load('weights_avg')
Animate with the default reducer (PCA); legend names the two groups. backend=’matplotlib’: unpacking into (fig, ani) is the matplotlib animation’s form; on Colab the default backend would be plotly
fig, ani = hyp.plot(data, animate=True, legend=['first', 'second'],
backend='matplotlib')
Any reducer can be combined with animation – here multidimensional scaling (MDS) replaces PCA.
fig, ani_mds = hyp.plot(data, animate=True, reduce='MDS', backend='matplotlib')
Total running time of the script: (0 minutes 22.062 seconds)