【发布时间】:2015-01-25 19:37:42
【问题描述】:
我正在尝试对 matplotlib.pyplot.plot 对象使用方法“set_data”和“set_3d_properties”。
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation
class animationObj(object):
def __init__(self):
self.fig= plt.figure()
self.ax = self.fig.add_subplot(111, projection='3d')
self.plot = []
self.plot.append(self.ax.plot([0], [0], [0], 'bo', markersize=10)[0])
self.ani = animation.FuncAnimation(self.fig, self, frames=range(0,10), interval=50, repeat_delay=1000)
def show(self):
return plt.show()
def __call__(self, i):
self.plot[0].set_data([x[i]], [y[i]])
self.plot[0].set_3d_properties([z[i]], 'z')
return self.plot[0]
我使用了以下示例:http://matplotlib.org/1.4.2/examples/animation/simple_3danim.html
但似乎 set_data 和 set_3d_properties 无法正常工作。有谁知道我做错了什么?
【问题讨论】:
标签: python matplotlib