【发布时间】:2020-04-23 08:30:55
【问题描述】:
假设我有一本字典如下:
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() 但动画速度非常慢。
【问题讨论】:
-
你如何将'a'、'b'和'c'解释为行? x,y,z 是什么?起点是什么?变量
locations是什么?你能创建一个minimal reproducible example吗? -
你如何将'a'、'b'和'c'解释为行? x,y,z 是什么?起点是什么?变量
locations是什么?你能创建一个minimal reproducible example吗? -
@JohanC 我用通用解决方案回答了我的问题
标签: python numpy matplotlib 3d