所以可以说我有如下字典:
dictionary = {'a': [1,2,3], 'b':[4,2,5], 'c':[5,9,1]}
因此,我将对所有'a','b','c'线进行单个绘制的方式是(假设已经声明了数字,等等:]
#half-setup for animation
lines = []
mass = list(dictionary.keys()) #I know this is redundant but my 'mass' variable serves another purpose in my actual program
for i in range(len(mass)): #create a list of line objects with zero entries
a, = ax.plot([], [])
lines.append(a)
#single plot
for i in dictionary:
index = np.array(locations[i]) #convert to numpy
ax.plot(index[:,0],index[:,1],index[:,2])
plt.show()
因此,如何将其转换为动画3D图形?我已经尝试过plt.ion()和plt.pause(),但是动画非常缓慢。
这是我使用的以下一般实现,并且效果很好(涉及字典):