如何对数据字典进行动画处理(即,如何对多个3D数据点进行动画处理?

问题描述 投票:0回答:1

所以可以说我有如下字典:

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(),但是动画非常缓慢。

python numpy matplotlib 3d
1个回答
0
投票

这是我使用的以下一般实现,并且效果很好(涉及字典):

© www.soinside.com 2019 - 2024. All rights reserved.