我试图在matplotlib中获得一个散点图的三维动画,基于here发布的2d散点图动画和here发布的3d线图.
问题来自set_data和set_offsets不能在3D中工作,所以你应该使用set_3d_properties来处理z信息.玩它通常会窒息,但下面张贴的代码会运行.然而,透明度增加到足以使点在几帧后逐渐消失.我在这做错了什么?我希望这些点在盒子的边界内跳一段时间.即使将步长调整到非常小的尺寸也不会减慢透明度.
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
FLOOR = -10
CEILING = 10
class AnimatedScatter(object):
def __init__(self, numpoints=5):
self.numpoints = numpoints
self.stream = self.data_stream()
self.angle = 0
self.fig = plt.figure()
self.ax = self.fig.add_subplot(111,projection = '3d')
self.ani = animation.FuncAnimation(self.fig, self.update, interval=100,
init_func=self.setup_plot, blit=True)
def change_angle(self):
self.angle = (self.angle + 1)%360
def setup_pl