2

I have timeseries data in 3D:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

#  make data
xs, ys, zs = np.random.normal(0, 10, 1000), np.random.normal(0, 10, 1000), np.random.normal(0, 10, 1000)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('3D acceleration vector distribution')

#  make color change over time
cm = plt.get_cmap('Set2')
colors = np.linspace(0, 1, len(xs))
my_colors = cm(colors)

ax.scatter(0, 0, 0, 'o', c='r')  # mark origin
ax.scatter(xs, ys, zs, 'o', alpha=1, c=colors, edgecolors='None',
            cmap=cm)

Scatterplot of vector data with color changing as the plot marches along the index.

How do I animate the points appearing one at a time? I've found this answer but don't understand how to modify the updater functions so that the new points don't get rid of the old points.

Bonus: It would be great if the old points could fade away over time so that the volume doesn't get cluttered.

Community
  • 1
  • 1
crypdick
  • 16,152
  • 7
  • 51
  • 74

0 Answers0