2

我有 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)

矢量数据的散点图,随着绘图沿索引行进,颜色会发生变化。

如何为一次出现一个的点设置动画?我找到了这个答案,但不明白如何修改更新程序功能,以便新点不会摆脱旧点。

奖励:如果旧点可以随着时间的推移逐渐消失,这样音量就不会变得混乱,那就太好了。

4

0 回答 0